-
Notifications
You must be signed in to change notification settings - Fork 77
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
[GX-17505] Dismantle core-plugin #23
Conversation
|
||
#### errorMiddleware | ||
|
||
Executed after the `express` event. All middleware or middleware arrays returned from |
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.
Did you want to mention middleware functions
here?
}); | ||
|
||
it('adds the errorMiddleware', async () => { | ||
const errorMiddlewares = [spy()]; |
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.
are these spies reset and cleaned, probably want to use sinon
as sandbox here
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 comes from const { spy, stub } = require('sinon');
.
I am not creating global mocks or anything, do they need to be reset and clean?
- [createServers](#createservers) | ||
- [servers](#servers) | ||
- [Configuration](#configuration-1) | ||
- [LICENSE: MIT](#license-mit) |
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.
Good improvement in itself, but most of our warehouse modules use a license badge rather than adding section at the bottom. I think we want to be consistent, but not feeling strong about it at this point
const devServer = gasket.command === 'local'; | ||
|
||
// Retrieving the server handler | ||
const handler = gasket.exec('createServers', devServer)[0]; |
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.
I think this should be changed up slightly in a couple of ways:
- Let's not pass
devServer
through these several lifecycles.gasket.command === 'local'
will always be available and it looks like only the nextjs-plugin needs it fornextApp
. - Let's make the
createServers
lifecycle anexecWaterfall
, which gives plugins the opportunity to adjust the createServers options (serverOpts
). In our initial case, the express-plugin will add the handler to the config object, rather than just return a handle for the https-plugin to add. This will allow more flexibility and should be easier to document.
|
||
|
||
// Note: Not sure if this needs an await, maybe? | ||
exec('nextExpress', { expressApp, 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.
Yea, probably should await this, in case there are modifications that affect things down the chain.
Also, probably would be most clear for consuming hooks to name these instances as next
, and express
:
exec('nextExpress', { next: app, express: expressApp })
For some high-level context for additional reviewers, below is lifecycle flow @DanielSanudo and I discussed which he implemented here, to dismantle the core-plugin, where
|
@DanielSanudo also, you'll need these generator files moved to the nextjs-plugin: All except |
93df4e4
to
b0a45d7
Compare
serverOpts = await gasket.execWaterfall('createServers', serverOpts); | ||
|
||
// create-servers does not support http or https being `null` | ||
if (http) { |
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.
Update serverOpts
with http/https also before passing to lifecycle
Summary
Changelog
Test Plan