compose-middleware
Compose an array of middleware into a single function for use in Express, Connect, router, etc.
Last updated 8 years ago by blakeembrey .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install compose-middleware 
SYNC missed versions from official npm registry.

Compose Middleware

NPM version NPM downloads Build status Test coverage

Compose an array of middleware into a single function for use in Express, Connect, router, etc.

Installation

npm install compose-middleware --save

Usage

Compose multiple middleware functions into a single request middleware handler, with support for inline error handling middleware.

var express = require('express')
var compose = require('compose-middleware').compose

var app = express()

app.use(compose([
  function (req, res, next) {},
  function (err, req, res, next) {},
  function (req, res, next) {}
]))

P.S. The composed function takes three arguments. Express.js (and Connect, router) only accept error handlers of four arguments. If you want to return an error handler from compose instead, try the errors export - it works exactly the same, but exposes the four argument middleware pattern.

License

MIT

Current Tags

  • 5.0.1                                ...           latest (6 years ago)

11 Versions

  • 5.0.1                                ...           6 years ago
  • 5.0.0                                ...           7 years ago
  • 4.0.0                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE