-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
refactor(server): Provide file-service handlers in the root injector. #3042
refactor(server): Provide file-service handlers in the root injector. #3042
Conversation
lib/server.js
Outdated
@@ -17,7 +17,7 @@ const constant = require('./constants') | |||
const watcher = require('./watcher') | |||
const plugin = require('./plugin') | |||
|
|||
const createWebServer = require('./web-server').createWebServer | |||
const {createWebServer, createServeFile, createServeStaticFile, createFilesPromise} = require('./web-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.
Object destructuring not works on Node 4 - it's reason why build fails
06bb9a1
to
ae1fcc7
Compare
Ok thanks, fixed, tests pass. |
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.
Looks nice :)
lib/web-server.js
Outdated
createWebServer.$inject = ['injector', 'config'] | ||
|
||
module.exports = { | ||
'createWebServer': createWebServer, |
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.
It may be write simpler:
module.exports = {
createWebServer,
createServeFile,
createServeStaticFile,
createFilesPromise
}
By removing the creation of file-service handlers from the webserver, we create functions with better focus and we allow the file-service handlers to be used in beforeMiddlewaare. The only cost is that these objects are now visible to all modules rather than being private to webserver. The potential for collision seems small.
ae1fcc7
to
d196a0f
Compare
Done |
By removing the creation of file-service handlers from the webserver, we create functions with better
focus and we allow the file-service handlers to be used in beforeMiddlewaare. The only cost is that these objects are now visible to all modules rather than being private to webserver. The potential for collision seems small.