init.js
This file
Path
lib/middleware/init.js
43 lines · 853 bytes · JavaScript
Last changed by
Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45
History of this fileTake it
The walk stopped after 200 commits: lines older than 2ac2509 point at it.
4.13.1Douglas Christopher Wilsonbefore adoption2ac2509
lines 1–11why, one step back1/*!2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2013 Roman Shtylman5 * Copyright(c) 2014-2015 Douglas Christopher Wilson6 * MIT Licensed7 */89'use strict';1011/**Use setprototypeof module to replace __proto__ settingDouglas Christopher Wilsonbefore adoption6022567
lines 12–15why, one step back12 * Module dependencies.13 * @private14 */15Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45
line 16why, one step back16var setPrototypeOf = require('setprototypeof')Use setprototypeof module to replace __proto__ settingDouglas Christopher Wilsonbefore adoption6022567
lines 17–18why, one step back1718/**4.13.1Douglas Christopher Wilsonbefore adoption2ac2509
lines 19–34why, one step back19 * Initialization middleware, exposing the20 * request and response to each other, as well21 * as defaulting the X-Powered-By header field.22 *23 * @param {Function} app24 * @return {Function}25 * @api private26 */2728exports.init = function(app){29 return function expressInit(req, res, next){30 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');31 req.res = res;32 res.req = req;33 req.next = next;34Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45
lines 35–36why, one step back35 setPrototypeOf(req, app.request)36 setPrototypeOf(res, app.response)4.13.1Douglas Christopher Wilsonbefore adoption2ac2509
lines 37–43why, one step back3738 res.locals = res.locals || Object.create(null);3940 next();41 };42};43