socketioMEANseed/server/node_modules/express/lib/middleware/init.js
server/node_modules/express/lib/middleware/init.jsRaw
1/**
2 * Initialization middleware, exposing the
3 * request and response to eachother, as well
4 * as defaulting the X-Powered-By header field.
5 *
6 * @param {Function} app
7 * @return {Function}
8 * @api private
9 */
10
11exports.init = function(app){
12 return function expressInit(req, res, next){
13 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
14 req.res = res;
15 res.req = req;
16 req.next = next;
17
18 req.__proto__ = app.request;
19 res.__proto__ = app.response;
20
21 res.locals = res.locals || Object.create(null);
22
23 next();
24 };
25};
26