connect-compose

Compose connect middleware

connect-compose

Compose multiple connect middleware into single middleware.

var connect = require('connect')
var compose = require('connect-compose')
var app = connect()
 
function mw1 (reqresnext) {
  req.stuff = ['mw1']
  next()
}
 
function mw2 (reqresnext) {
  req.stuff.push('mw2')
  next()
}
 
function mw3 (reqres) {
  res.end(req.stuff.join(','))
}
 
app.use(compose([mw1, mw2]))
app.use(mw3)
 
app.listen(6060)
 

MIT