I want to be able to pass different requests through different Express middleware stacks.
I think I need two express app
s, and some way to branch. e.g.:
var app = express();
var alt_app = express();
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(function(req, res, next) {
if (some_condition(req)) {
divert_request_to_alt_app();
} else {
next();
}
}
app.use(middleware_that_must_not_affect_alt_app());
alt_app.use(middleware_that_only_affects_alt_app());
Is such a strategy possible?
If so, what should divert_request_to_alt_app()
be?
If not, what are other approaches?