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 51f5290 point at it.
Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 1–15why, 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/**12 * Module dependencies.13 * @private14 */15Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45
line 16why, one step back16var setPrototypeOf = require('setprototypeof')Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 17–34why, one step back1718/**19 * 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)Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 37–43why, one step back3738 res.locals = res.locals || Object.create(null);3940 next();41 };42};43