Thanks for contributing to Nest Middlewares! This document outlines the best practice for adding your own middleware of choice.
- Duplicate the
tpl
folder and move it intosrc
. - Rename
tpl
to the exact name of the middleware as it is on NPM. For example, for Helmet, usehelmet
, or forbody-parser
, usebody-parser
. - In
package.json
, rename thename
property to@nest-middlewares/MIDDLEWARE_NAME
, where MIDDLEWARE_NAME is the same name as the middleware on NPM. Also, be sure to change the name ofMiddleware
in the description field ofpackage.json
. npm install
the types for your middleware in the root folder (for example,npm install --save-dev @types/helmet
). Make sure they are saved todevDependencies
of the root package.json.cd
into your newly created middleware folder, andnpm install
the package containing the middleware and save it topackage.json
(for example,npm install --save helmet
).- In
index.ts
, change all the instances of "middleware" to what they should logically be named, maintaining capitalization. Check out CONTRIBUTING.md for clarification. - Write tests as necessary for your middleware.
- Run
sh ./scripts/build.sh
and make sure that no errors arise. - Run
lerna clean && lerna bootstrap
and make sure no errors arise. - 🎉 Congratulations! You've made a middleware! File a pull request, and sit back and look at your great work.