source: trip-planner-front/node_modules/express/lib/express.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*!
2 * express
3 * Copyright(c) 2009-2013 TJ Holowaychuk
4 * Copyright(c) 2013 Roman Shtylman
5 * Copyright(c) 2014-2015 Douglas Christopher Wilson
6 * MIT Licensed
7 */
8
9'use strict';
10
11/**
12 * Module dependencies.
13 */
14
15var bodyParser = require('body-parser')
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');
23
24/**
25 * Expose `createApplication()`.
26 */
27
28exports = module.exports = createApplication;
29
30/**
31 * Create an express application.
32 *
33 * @return {Function}
34 * @api public
35 */
36
37function createApplication() {
38 var app = function(req, res, next) {
39 app.handle(req, res, next);
40 };
41
42 mixin(app, EventEmitter.prototype, false);
43 mixin(app, proto, false);
44
45 // expose the prototype that will get set on requests
46 app.request = Object.create(req, {
47 app: { configurable: true, enumerable: true, writable: true, value: app }
48 })
49
50 // expose the prototype that will get set on responses
51 app.response = Object.create(res, {
52 app: { configurable: true, enumerable: true, writable: true, value: app }
53 })
54
55 app.init();
56 return app;
57}
58
59/**
60 * Expose the prototypes.
61 */
62
63exports.application = proto;
64exports.request = req;
65exports.response = res;
66
67/**
68 * Expose constructors.
69 */
70
71exports.Route = Route;
72exports.Router = Router;
73
74/**
75 * Expose middleware
76 */
77
78exports.json = bodyParser.json
79exports.query = require('./middleware/query');
80exports.raw = bodyParser.raw
81exports.static = require('serve-static');
82exports.text = bodyParser.text
83exports.urlencoded = bodyParser.urlencoded
84
85/**
86 * Replace removed middleware with an appropriate error message.
87 */
88
89var removedMiddlewares = [
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',
106 'staticCache'
107]
108
109removedMiddlewares.forEach(function (name) {
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: true
115 });
116});
Note: See TracBrowser for help on using the repository browser.