Connectr is a layer on top of Connect that allows the insertion/removal of middlewares after the stack has been built. This is especially useful when you don't have access to the code that sets up your Connect stack (a third party module for example).
This module also supports Express.
npm install connectr
var connectr = app;// you can also monkey patch app directly:// app = require('connectr').patch(app)// Add labeled middlewareconnectr;// Label middleware which is at a specific position on the stack// This should be used only if you don't have access to the code// that builds the stack.//// Tip: use `app.stack` to inspect the stackconnectrindexindex;// Insert before middlewareconnectr;// Insert after middlewareconnectr;// Insert at beginning of stackconnectr;// Remove middlewareconnectr;// Assign a label to middleware already in the stackconnectrindexi;// the .as, .before and .after calls are optional// have a problem? try console.log(app.stack)
var connect =var app = ;var connectr = app;connectr;/* ... */connectr;
var http =connect =app =connectr = app;var cookieParser = connect;// we need to manually label middlewarescookieParserlabel = 'cookieParser';app;connectr;connectr;// you can also use connectr to label your middlewares// instead of labeling them manually as aboveconnectr;connectr;connectr;connectr;connectr;//console.log(app.stack);http;