github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example-nodejs-fileserver/node_modules/express/lib/express.js (about) 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 15 var EventEmitter = require('events').EventEmitter; 16 var mixin = require('merge-descriptors'); 17 var proto = require('./application'); 18 var Route = require('./router/route'); 19 var Router = require('./router'); 20 var req = require('./request'); 21 var res = require('./response'); 22 23 /** 24 * Expose `createApplication()`. 25 */ 26 27 exports = module.exports = createApplication; 28 29 /** 30 * Create an express application. 31 * 32 * @return {Function} 33 * @api public 34 */ 35 36 function createApplication() { 37 var app = function(req, res, next) { 38 app.handle(req, res, next); 39 }; 40 41 mixin(app, EventEmitter.prototype, false); 42 mixin(app, proto, false); 43 44 app.request = { __proto__: req, app: app }; 45 app.response = { __proto__: res, app: app }; 46 app.init(); 47 return app; 48 } 49 50 /** 51 * Expose the prototypes. 52 */ 53 54 exports.application = proto; 55 exports.request = req; 56 exports.response = res; 57 58 /** 59 * Expose constructors. 60 */ 61 62 exports.Route = Route; 63 exports.Router = Router; 64 65 /** 66 * Expose middleware 67 */ 68 69 exports.query = require('./middleware/query'); 70 exports.static = require('serve-static'); 71 72 /** 73 * Replace removed middleware with an appropriate error message. 74 */ 75 76 [ 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: true 102 }); 103 });