How would I go about ensuring that a particular object is available to every request I handle in express?
var somethingImportant = "really important";
var app = express();
// This is just a hypothetical example of what I'm after...
app.mixThisInWithRequest({
somethingImportant: somethingImportant
});
app.use(function (request, response, next) {
console.log(request.somethingImportant);
});
Given the example above, is there a facility akin to the mixThisInWithRequest function?
Add it to the
requestobject in middleware, as early in theapp.usechain as you need it: