An idea:
var config = require('./config');
where you have the constants, etc....
and access it from your middleware. The problem: each middleware should know where is the required file (in the above code, it is in the same directory of the program that makes the require).
Another option: write a module like the above one, but install it in your node_modules, referring it from your package.json
But I prefer this one:
- Write a middleware that enrich the req object, something like
funcion (req, res, next) {
req.context = require('./context');
next();
}
and add it as your FIRST middleware in the chain
Angel "Java" Lopez
@ajlopez