I have an app with controllers in several files, like this:
var aRoutes = require('./controllers/controllerA');
var bRoutes = require('./controllers/controllerB');
var cRoutes = require('./controllers/controllerC');
app.use('/a', aRoutes);
app.use('/b', bRoutes);
app.use('/c', cRoutes);
// ... several more
And I have a middleware function like this...
app.use(function (req, res, next) {
// do a middleware thing
// but not if route == x or y or z or ... yuck!
});
And I want that middleware to run on everything except the aRoutes. I've seen an answer like this, which suggests adding a check in the middleware fn for every route to be excluded but that's terrible, I think. There might be a lot of routes to check, and it forces me to touch the code in two places when I add one of those exception routes.
There must be a better way, right?