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