express.js
This file
Path
lib/express.js
103 lines · 1.9 KiB · JavaScript
Last changed by
perf: enable strict modeDouglas Christopher Wilsonbefore adoptione71014f
History of this fileTake it
The walk stopped after 200 commits: lines older than 6bc7574 point at it.
docs: add license commentsDouglas Christopher Wilsonbefore adoption95ad276
lines 1–8why, 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 */8perf: enable strict modeDouglas Christopher Wilsonbefore adoptione71014f
lines 9–10why, one step back9'use strict';10docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 11–15why, one step back11/**12 * Module dependencies.13 */1415var EventEmitter = require('events').EventEmitter;Merge tag '3.18.1'Douglas Christopher Wilsonbefore adoptionccc45a7
line 16why, one step back16var mixin = require('merge-descriptors');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 17–40why, one step back17var proto = require('./application');18var Route = require('./router/route');19var Router = require('./router');20var req = require('./request');21var res = require('./response');2223/**24 * Expose `createApplication()`.25 */2627exports = module.exports = createApplication;2829/**30 * Create an express application.31 *32 * @return {Function}33 * @api public34 */3536function createApplication() {37 var app = function(req, res, next) {38 app.handle(req, res, next);39 };40Fix constructing application with non-configurable prototype propertiesDouglas Christopher Wilsonbefore adoption31cb541
lines 41–42why, one step back41 mixin(app, EventEmitter.prototype, false);42 mixin(app, proto, false);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 43–103why, one step back4344 app.request = { __proto__: req, app: app };45 app.response = { __proto__: res, app: app };46 app.init();47 return app;48}4950/**51 * Expose the prototypes.52 */5354exports.application = proto;55exports.request = req;56exports.response = res;5758/**59 * Expose constructors.60 */6162exports.Route = Route;63exports.Router = Router;6465/**66 * Expose middleware67 */6869exports.query = require('./middleware/query');70exports.static = require('serve-static');7172/**73 * Replace removed middleware with an appropriate error message.74 */7576[77 'json',78 'urlencoded',79 'bodyParser',80 'compress',81 'cookieSession',82 'session',83 'logger',84 'cookieParser',85 'favicon',86 'responseTime',87 'errorHandler',88 'timeout',89 'methodOverride',90 'vhost',91 'csrf',92 'directory',93 'limit',94 'multipart',95 'staticCache',96].forEach(function (name) {97 Object.defineProperty(exports, name, {98 get: function () {99 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.');100 },101 configurable: true102 });103});