Enable enhanced customization of server options#292
Enable enhanced customization of server options#292JakeDetels wants to merge 3 commits intobroccolijs:mainfrom
Conversation
|
@joliss: Any feedback? |
|
@joliss @JakeDetels When do you merge this feature? I need this feature for adding custom headers to server response. Thank you |
|
@JakeDetels / @oksuz sorry for the long delay in response. I believe in broad-strokes I agree with this approach. The code-base has changed some, if you are still using broccoli and would like to rebase and update the code. I would love to revisit this, and help get it in. |
|
@stefanpenner: I'll aim to get this PR updated by the end of the month (12/31/2017). If needed sooner, let me know. |
|
Friendly ping 🏂 |
|
Faced the issue today, this PR would be very helpful 😊 |
|
I like idea about additional customization, but I think having multiple ways to do it - not an optimal direction. We could have // module.exports = async function({env, mode} : { env: 'prod' | 'dev'; mode: 'build' | 'serve' }) {
return {
port: 4011,
host: '192.168.1.1',
staticHeaders: {
'Access-Control-Alow-Origin': '*'
},
middleware: {
onError(req, resp, error) {
//tbd
},
onRequest(req, resp, next) {
//tbd
},
postRequest(req, resp) {
//tbd
}
}
}
} |
This pull request aims to enhance the user's ability to customize the options passed to
broccoli.server.serve()in a couple different ways.First, users can customize the http response headers created within
lib/middleware.jsby including aheadersproperty in the main options object passed inbroccoli.server.serve(builder, options). For example, the following options would enable Broccoli to include a CORS header when serving files onhttp://localhost:4200:To allow advanced options like these to be easier configure when using Broccoli CLI, this pull request also expands on
lib/cli.jsby allowing users to define an optional.broccoliJSON-formatted file within the root directory of their projects. Any configurations defined within that.broccolifile will be pulled whenever callingbroccoli serve. For example, the following.broccolifile would cause Broccoli to serve on port 12345 with a CORS header:This pull request includes 5 new passing tests in
test/options_test.js. To help clean up the console output when running Mocha, there is new option defined calleddisableLoggingwhich (when set totrue) will causelib/server.jsto not callconsole.log()while the Mocha tests are running.