rc@73: /** rc@73: * Module dependencies. rc@73: */ rc@73: rc@73: var EventEmitter = require('events').EventEmitter; rc@73: var mixin = require('utils-merge'); rc@73: var proto = require('./application'); rc@73: var Route = require('./router/route'); rc@73: var Router = require('./router'); rc@73: var req = require('./request'); rc@73: var res = require('./response'); rc@73: rc@73: /** rc@73: * Expose `createApplication()`. rc@73: */ rc@73: rc@73: exports = module.exports = createApplication; rc@73: rc@73: /** rc@73: * Create an express application. rc@73: * rc@73: * @return {Function} rc@73: * @api public rc@73: */ rc@73: rc@73: function createApplication() { rc@73: var app = function(req, res, next) { rc@73: app.handle(req, res, next); rc@73: }; rc@73: rc@73: mixin(app, proto); rc@73: mixin(app, EventEmitter.prototype); rc@73: rc@73: app.request = { __proto__: req, app: app }; rc@73: app.response = { __proto__: res, app: app }; rc@73: app.init(); rc@73: return app; rc@73: } rc@73: rc@73: /** rc@73: * Expose the prototypes. rc@73: */ rc@73: rc@73: exports.application = proto; rc@73: exports.request = req; rc@73: exports.response = res; rc@73: rc@73: /** rc@73: * Expose constructors. rc@73: */ rc@73: rc@73: exports.Route = Route; rc@73: exports.Router = Router; rc@73: rc@73: /** rc@73: * Expose middleware rc@73: */ rc@73: rc@73: exports.query = require('./middleware/query'); rc@73: exports.static = require('serve-static'); rc@73: rc@73: /** rc@73: * Replace removed middleware with an appropriate error message. rc@73: */ rc@73: rc@73: [ rc@73: 'json', rc@73: 'urlencoded', rc@73: 'bodyParser', rc@73: 'compress', rc@73: 'cookieSession', rc@73: 'session', rc@73: 'logger', rc@73: 'cookieParser', rc@73: 'favicon', rc@73: 'responseTime', rc@73: 'errorHandler', rc@73: 'timeout', rc@73: 'methodOverride', rc@73: 'vhost', rc@73: 'csrf', rc@73: 'directory', rc@73: 'limit', rc@73: 'multipart', rc@73: 'staticCache', rc@73: ].forEach(function (name) { rc@73: Object.defineProperty(exports, name, { rc@73: get: function () { rc@73: 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.'); rc@73: }, rc@73: configurable: true rc@73: }); rc@73: });