3 * Copyright(c) 2009-2013 TJ Holowaychuk
4 * Copyright(c) 2013 Roman Shtylman
5 * Copyright(c) 2014-2015 Douglas Christopher Wilson
12 * Module dependencies.
15 var bodyParser = require('body-parser')
16 var EventEmitter = require('events').EventEmitter;
17 var mixin = require('merge-descriptors');
18 var proto = require('./application');
19 var Route = require('./router/route');
20 var Router = require('./router');
21 var req = require('./request');
22 var res = require('./response');
25 * Expose `createApplication()`.
28 exports = module.exports = createApplication;
31 * Create an express application.
37 function createApplication() {
38 var app = function(req, res, next) {
39 app.handle(req, res, next);
42 mixin(app, EventEmitter.prototype, false);
43 mixin(app, proto, false);
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 }
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 }
60 * Expose the prototypes.
63 exports.application = proto;
64 exports.request = req;
65 exports.response = res;
68 * Expose constructors.
71 exports.Route = Route;
72 exports.Router = Router;
78 exports.json = bodyParser.json
79 exports.query = require('./middleware/query');
80 exports.raw = bodyParser.raw
81 exports.static = require('serve-static');
82 exports.text = bodyParser.text
83 exports.urlencoded = bodyParser.urlencoded
86 * Replace removed middleware with an appropriate error message.
89 var removedMiddlewares = [
109 removedMiddlewares.forEach(function (name) {
110 Object.defineProperty(exports, name, {
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.');