-
Notifications
You must be signed in to change notification settings - Fork 72
Middleware hooks #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Middleware hooks #24
Conversation
package.json
Outdated
| "express": "^4.13.3", | ||
| "fastboot": "^1.0.0-rc.0", | ||
| "fastboot-express-middleware": "^1.0.0-rc.3", | ||
| "fastboot-express-middleware": "dollarshaveclub/fastboot-express-middleware#b975bb3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to a released version before merge.
test/app-server-test.js
Outdated
| }); | ||
|
|
||
| it("executes preFastbootMiddlewares", function() { | ||
| return runServer('prefastboot-middleware-server') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed at the meeting this week that the API for this should be to expose pre-FastBoot middleware and post-FastBoot middleware callbacks that yield the Express app itself. This is a more flexible API that is not limited to just middleware, and lets folks use the Express API they're already familiar with instead of learning something custom to the FastBoot App Server.
e198817 to
ea0be49
Compare
|
|
||
| this.preFastbootMiddlewares(app); | ||
|
|
||
| if (this.gzip) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to move this code to get the execution order right.
src/express-http-server.js
Outdated
| let username = this.username; | ||
| let password = this.password; | ||
|
|
||
| this.preFastbootMiddlewares(app); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| res.send(); | ||
| } | ||
|
|
||
| var server = new FastBootAppServer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomdale this pattern would be how you would use the middleware hooks.
README.md
Outdated
|
|
||
| const server = FastBootAppServer({ | ||
| preFastbootMiddlewares: function (app) { app.use(modifyRequest); }, | ||
| postFastbootMiddlewares: function (app) { app.use(handleErrors); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little verbose, and I think middleware is an irregular plural, right? "Middlewares" sounds strange to me.
Maybe something like:
beforeMiddlewareafterMiddleware
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should do it
2c19e4e to
d5e5a80
Compare
|
This is awesome. Thank you @arjansingh! |
I just thought I'd start the review.
Requires ember-fastboot/fastboot-express-middleware#11 before we can merge.