middleware.js
This file
Path
lib/middleware.js
33 lines · 615 bytes · JavaScript
Last changed by
removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334
/** * Module dependencies. */
var utils = require('./utils');
/** * Initialization middleware, exposing the * request and response to eachother, as well * as defaulting the X-Powered-By header field. * * @param {Function} app * @return {Function} * @api private */
exports.init = function(app){ return function expressInit(req, res, next){ req.app = res.app = app; res.setHeader('X-Powered-By', 'Express'); req.res = res; res.req = req; req.next = next;
req.__proto__ = app.request; res.__proto__ = app.response;
res.locals = utils.locals(res);
next(); }};