Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than dd2b897 point at it.

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

lines 1–11why, one step back
1/*!
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 back
12 * Module dependencies.
13 * @private14 */15

Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45

line 16why, one step back
16var setPrototypeOf = require('setprototypeof')

Use setprototypeof module to replace __proto__ settingDouglas Christopher Wilsonbefore adoption6022567

lines 17–18why, one step back
17
18/**

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

lines 19–34why, one step back
19 * Initialization middleware, exposing the
20 * 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;34

Fix typo in variable name setPrototypeOfasaf davidbefore adoptionc087a45

lines 35–36why, one step back
35 setPrototypeOf(req, app.request)
36 setPrototypeOf(res, app.response)

examples: comment the usage of process.nextTickMuhammad Saqibbefore adoptiondd2b897

lines 37–43why, one step back
37
38 res.locals = res.locals || Object.create(null);3940 next();41 };42};43