Skip to content
Common, injectable middlewares for NestJS
Branch: master
Clone or download
wbhob Fix issue #20 (#22)
Fix issue #20
Latest commit 077baf8 May 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode v5.1.0 Aug 14, 2018
packages fix: missing the else case May 4, 2019
scripts refactor(): contain everything to packages dir Nov 24, 2017
template feat: migrate to nestjs 6 Mar 26, 2019
test fix: ci coverage Mar 27, 2019
types removed custom types Sep 23, 2018
.gitignore chore(): remove built code Nov 24, 2017
.npmignore refactor(): contain everything to packages dir Nov 24, 2017
.npmrc v1.0.0 Nov 24, 2017
.travis.yml fix: ci coverage Mar 27, 2019
CHANGELOG.md changelog 6.0.0 Apr 2, 2019
CONTRIBUTING.md Update CONTRIBUTING.md May 3, 2019
LICENSE Initial commit Nov 23, 2017
README.md Update README.md May 3, 2019
lerna.json v6.0.0 Mar 23, 2019
package-lock.json revert version number Apr 2, 2019
package.json revert version number Apr 2, 2019
tsconfig.json refactor(): contain everything to packages dir Nov 24, 2017
tslint.json

README.md

Coverage Status

Nest Middlewares

Add the most common Express middlewares to your Nest app with one line.

System Requirements

This packages requires the following:

  • Node.JS 8.0.0 or later
  • @nestjs/core and @nestjs/common 6.0.0 or later

Adding Middlewares

Please do not open issues asking to support a middleware – I've tried to make this project really easy to implement and extend. See CONTRIBUTING.md for more information on how to create a new middleware, and I'll merge and release it if it meets the contributing guidelines. Thank you for your contribution.

Usage

Take the name of your favorite Express middleware and prefix it with @nest-middlewares/.

$ npm install --save @nest-middlewares/helmet

In your module:

import { HelmetMiddleware } from '@nest-middlewares/helmet'; // (look around in the source code for the exact class name)

@Module(...)
export class MyModule {
    configure(consumer: MiddlewaresConsumer) {
        // IMPORTANT! Call Middleware.configure BEFORE using it for routes
        HelmetMiddleware.configure( /* options as per helmet docs */ )
        consumer.apply(HelmetMiddleware).forRoutes(
            /* your routes */
        );
    }
}

Currently supports:

  • Compression
  • Connect RID
  • Connect Timeout
  • Cookie Parser
  • Cookie Session
  • CORS
  • Csurf
  • Error Handler
  • Helmet
  • Method Override
  • Morgan
  • Response Time
  • Serve Favicon
  • Serve Index
  • Serve Static
  • VHost
You can’t perform that action at this time.