File: chat-websocket/node_modules/express/lib/middleware.js

Recommend this page to a friend!
  Classes of Igor Escobar  >  Terminal Crossword  >  chat-websocket/node_modules/express/lib/middleware.js  >  Download  
File: chat-websocket/node_modules/express/lib/middleware.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Terminal Crossword
Generate a crosswords board on a text console
Author: By
Last change:
Date: 5 months ago
Size: 663 bytes
 

Contents

Class file image Download
/**
 * Module dependencies.
 */

var utils = require('./utils');

/**
 * Initialization middleware, exposing the
 * request and response to eachother, as well
 * as defaulting the X-Powered-By header field.
 *
 * @param {Function} app
 * @return {Function}
 * @api private
 */

exports.init = function(app){
  return function expressInit(req, res, next){
    req.app = res.app = app;
    if (app.settings['x-powered-by']) res.setHeader('X-Powered-By', 'Express');
    req.res = res;
    res.req = req;
    req.next = next;

    req.__proto__ = app.request;
    res.__proto__ = app.response;

    res.locals = res.locals || utils.locals(res);

    next();
  }
};