Hi, I have two middlewares created by express() function :
// module_a.js
var express = require('express')
app = express();
...
module.exports = app
// module_b.js
var express = require('express')
app = express();
...
module.exports = app
now, in the main module, I want to use only one of the middlewares, based on a query parameter. Something like this:
// main.js
app.use(function(req, res) {
if (req.query.something) {
app.use(module_a); // and pass req, res somehow to that middleware
} else {
app.use(module_b) // and pass req, res somehow to that middleware
}
});
since the result of express() is an object, as opposed to a function usually passed to app.use() I have no way of doing it.
Any idea ?
Thanks