Skip to content
Myr

express.js

This file

Path

lib/express.js

116 lines · 2.4 KiB · JavaScript

Last changed by

Add express.text to parse bodies into stringIlya Gutermanbefore adoption7f4e37f

History of this file

Take it

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

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

lines 1–14why, 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/**12 * Module dependencies.13 */14

Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8

line 15why, one step back
15var bodyParser = require('body-parser')

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

lines 16–77why, one step back
16var 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 */77

Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8

line 78why, one step back
78exports.json = bodyParser.json

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

line 79why, one step back
79exports.query = require('./middleware/query');

Add express.raw to parse bodies into BufferAmit Zurbefore adoption0bcdd88

line 80why, one step back
80exports.raw = bodyParser.raw

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

line 81why, one step back
81exports.static = require('serve-static');

Add express.text to parse bodies into stringIlya Gutermanbefore adoption7f4e37f

line 82why, one step back
82exports.text = bodyParser.text

Add express.json and express.urlencoded to parse bodiesDouglas Christopher Wilsonbefore adoptionc0136d8

line 83why, one step back
83exports.urlencoded = bodyParser.urlencoded

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

lines 84–88why, one step back
84
85/**86 * Replace removed middleware with an appropriate error message.87 */88

lint: move removed middlewares list to a variableLinus Unnebäckbefore adoption431f653

line 89why, one step back
89var removedMiddlewares = [

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

lines 90–105why, one step back
90 'bodyParser',
91 'compress',92 'cookieSession',93 'session',94 'logger',95 'cookieParser',96 'favicon',97 'responseTime',98 'errorHandler',99 'timeout',100 'methodOverride',101 'vhost',102 'csrf',103 'directory',104 'limit',105 'multipart',

lint: move removed middlewares list to a variableLinus Unnebäckbefore adoption431f653

lines 106–109why, one step back
106 'staticCache'
107]108109removedMiddlewares.forEach(function (name) {

docs: fix GitHub capitalizationPiper Chesterbefore adoption43dff4c

lines 110–116why, one step back
110 Object.defineProperty(exports, name, {
111 get: function () {112 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.');113 },114 configurable: true115 });116});