middleware.js
This file
Path
lib/middleware.js
32 lines · 633 bytes · JavaScript
Last changed by
Merge pull request #1650 from printercu/masterTJ Holowaychukbefore adoptionaec3428
History of this fileTake it
The walk stopped after 200 commits: lines older than a10f695 point at it.
pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 1–32why, one step back12/**3 * Module dependencies.4 */56var utils = require('./utils');78/**9 * Initialization middleware, exposing the10 * request and response to eachother, as well11 * as defaulting the X-Powered-By header field.12 *13 * @param {Function} app14 * @return {Function}15 * @api private16 */1718exports.init = function(app){19 return function expressInit(req, res, next){20 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');21 req.res = res;22 res.req = req;23 req.next = next;2425 req.__proto__ = app.request;26 res.__proto__ = app.response;2728 res.locals = res.locals || utils.locals(res);2930 next();31 }32};