-
Notifications
You must be signed in to change notification settings - Fork 59
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
Status endpoints #53
Merged
Merged
Status endpoints #53
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.git | ||
.env | ||
node_modules | ||
Dockerfile | ||
.dockerignore | ||
npm-debug.log | ||
.storybook | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const env = require('./env'); | ||
|
||
const { middleware } = env.PLUGINS_MODULE ? require(env.PLUGINS_MODULE) : {}; | ||
|
||
if (Array.isArray(middleware)) { | ||
module.exports.applyMiddleware = app => middleware.forEach(m => m(app)); | ||
} else if (middleware !== undefined) { | ||
console.log( | ||
`Expected middleware to be of type Array, but got ${middleware} instead` | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Won't this case always be hit when there is no
env.PLUGINS_MODULE
set? is that desired?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.
Perhaps the conditional should be
else
to handle all the other cases here. That would cover the case whererequire(env.PLUGINS_MODULE).middleware
resolves toundefined
. The code as it is written wouldn't export anything, nor log anything to the console.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.
sorry, 🤦♂ you are right. I misread the destructuring on that assignment... disregard
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.
Looking at it now, I realize I may have been a little cryptic with this code. The intended behavior is that if you specify
env.PLUGINS_MODULE
, and it exports an object with propertymiddleware
, that property will be an array.If it is not an array, or it is undefined, we will ignore it altogether. Plugins/middleware are completely optional and shouldn't interrupt the startup with an error.
The
else if
case was meant to be informational. In the event that you set the environment variable and your module exports a value, you clearly want to add middleware. So we let you know why we can't use your value.And in the case where
require(env.PLUGINS_MODULE).middleware
resolves to undefined, we aren't modifyingmodule.exports
. This will result in the module exporting an empty object. To me that seems like the desirable behavior. But it's probably not clear what conventions/behaviors are expected here.Maybe this could use more documentation and more robust logging in all cases?