Skip to content
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

Merged
merged 1 commit into from
Jun 15, 2018

Conversation

johnjbarton
Copy link
Contributor

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.

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')
Copy link
Contributor

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

@johnjbarton
Copy link
Contributor Author

Ok thanks, fixed, tests pass.

@johnjbarton johnjbarton requested a review from lusarz June 15, 2018 15:29
Copy link
Contributor

@lusarz lusarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice :)

createWebServer.$inject = ['injector', 'config']

module.exports = {
'createWebServer': createWebServer,
Copy link
Contributor

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.
@johnjbarton
Copy link
Contributor Author

Done

@johnjbarton johnjbarton merged commit a32ba27 into karma-runner:master Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants