Connectr is a Node.js module I wrote that aims to solve the following problem: how to manipulate the Connect stack after it has been created.

This is a problem I faced while writing a REST framework on top of Express.js. The framework initialized the middleware stack but there was no easy way to expose the stack to end users of the framework so they could add their own middlewares at arbitrary positions on the stack.


npm install connectr


var connectr = require('connectr')(app);

// Add labeled middleware

// Insert before middleware

// Insert after middleware

// Remove middleware

// the .as, .before and .after calls are optional

Simple Example

var connect = require('connect'),
var app = connect();
var connectr = require('connectr')(app);


/* ... */

connectr.before('cookieParser').use(function (req, res, next) {
  console.log('Before cookie parser...');
}).as('log before cookie parser');

I am hoping the methods that Connectr provide can eventually be supported natively by Connect but until then, Connectr does the job.

If you use Connectr, please star the project on Github to show your support.

Happy coding!