express.js
This file
Path
lib/express.js
114 lines · 2.3 KiB · JavaScript
Last changed by
lint: move removed middlewares list to a variableLinus Unnebäckbefore adoption431f653
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–14why, 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 */14Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8
line 15why, one step back15var bodyParser = require('body-parser')Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 16–77why, one step back16var EventEmitter = require('events').EventEmitter;17var mixin = require('merge-descriptors');18var proto = require('./application');19var Route = require('./router/route');20var Router = require('./router');21var req = require('./request');22var res = require('./response');2324/**25 * Expose `createApplication()`.26 */2728exports = module.exports = createApplication;2930/**31 * Create an express application.32 *33 * @return {Function}34 * @api public35 */3637function createApplication() {38 var app = function(req, res, next) {39 app.handle(req, res, next);40 };4142 mixin(app, EventEmitter.prototype, false);43 mixin(app, proto, false);4445 // expose the prototype that will get set on requests46 app.request = Object.create(req, {47 app: { configurable: true, enumerable: true, writable: true, value: app }48 })4950 // expose the prototype that will get set on responses51 app.response = Object.create(res, {52 app: { configurable: true, enumerable: true, writable: true, value: app }53 })5455 app.init();56 return app;57}5859/**60 * Expose the prototypes.61 */6263exports.application = proto;64exports.request = req;65exports.response = res;6667/**68 * Expose constructors.69 */7071exports.Route = Route;72exports.Router = Router;7374/**75 * Expose middleware76 */77Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8
line 78why, one step back78exports.json = bodyParser.jsonFix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 79–80why, one step back79exports.query = require('./middleware/query');80exports.static = require('serve-static');Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8
line 81why, one step back81exports.urlencoded = bodyParser.urlencodedFix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 82–86why, one step back8283/**84 * Replace removed middleware with an appropriate error message.85 */86lint: move removed middlewares list to a variableLinus Unnebäckbefore adoption431f653
line 87why, one step back87var removedMiddlewares = [Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 88–103why, one step back88 'bodyParser',89 'compress',90 'cookieSession',91 'session',92 'logger',93 'cookieParser',94 'favicon',95 'responseTime',96 'errorHandler',97 'timeout',98 'methodOverride',99 'vhost',100 'csrf',101 'directory',102 'limit',103 'multipart',lint: move removed middlewares list to a variableLinus Unnebäckbefore adoption431f653
lines 104–107why, one step back104 'staticCache'105]106107removedMiddlewares.forEach(function (name) {Fix case where router.use skipped requests routes did notDouglas Christopher Wilsonbefore adoption51f5290
lines 108–114why, one step back108 Object.defineProperty(exports, name, {109 get: function () {110 throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');111 },112 configurable: true113 });114});