![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@gasket/plugin-express
Advanced tools
Adds Express to your application.
npm i @gasket/plugin-express
Update your gasket
file plugin configuration:
// gasket.js
+ import pluginExpress from '@gasket/plugin-express';
export default makeGasket({
plugins: [
+ pluginExpress
]
});
All the configurations for the plugin are added under express
in the config:
compression
: true by default. Can be set to false if applying compression
differently.excludedRoutesRegex
: (deprecated) renamed to more correct middlewareInclusionRegex
.middlewareInclusionRegex
: RegExp filter to apply toward request URLs to determine when Gasket middleware will run. You can use negative lookahead patterns to exclude routes like static resource paths.export default makeGasket({
plugins: [
pluginExpress
],
express: {
compression: false,
middlewareInclusionRegex: /^(?!\/_next\/)/,
trustProxy: true
}
});
Routes can be defined in a in-app plugin in the plugins
directory. The plugin will hook the express
lifecycle to add the routes to the express app.
// plugins/routes-plugin.js
export default {
name: 'routes-plugin',
hooks: {
express: async function (gasket, app) {
app.get('/hello', (req, res) => {
res.send('Hello World!');
});
}
}
};
Executed after the middleware
event for when you need full control over
the express
instance.
export default {
name: 'sample-plugin',
hooks: {
/**
* Update Express app instance
*
* @param {Gasket} gasket The Gasket API
* @param {Express} express Express app instance
* @returns {function|function[]} middleware(s)
*/
express: async function (gasket, express) {
}
}
};
Executed after the express
event. All middleware functions returned from this
hook will be applied to Express.
export default {
name: 'sample-plugin',
hooks: {
/**
* Add Express error middlewares
*
* @param {Gasket} gasket The Gasket API
* @returns {function|function[]} error middleware(s)
*/
errorMiddleware: function (gasket) {
}
}
};
This plugins hooks the createServers lifecycles from @gasket/plugin-https.
FAQs
Adds express support to your application
The npm package @gasket/plugin-express receives a total of 146 weekly downloads. As such, @gasket/plugin-express popularity was classified as not popular.
We found that @gasket/plugin-express demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.