2016-02-12 13:10:16 +00:00
/ * !
* express
* Copyright ( c ) 2009 - 2013 TJ Holowaychuk
* Copyright ( c ) 2013 Roman Shtylman
* Copyright ( c ) 2014 - 2015 Douglas Christopher Wilson
* MIT Licensed
* /
'use strict' ;
2015-07-20 13:42:07 +00:00
/ * *
* Module dependencies .
* /
2016-02-12 13:10:16 +00:00
var EventEmitter = require ( 'events' ) . EventEmitter ;
2015-07-20 13:42:07 +00:00
var mixin = require ( 'merge-descriptors' ) ;
2016-02-12 13:10:16 +00:00
var proto = require ( './application' ) ;
var Route = require ( './router/route' ) ;
var Router = require ( './router' ) ;
var req = require ( './request' ) ;
var res = require ( './response' ) ;
2015-07-20 13:42:07 +00:00
/ * *
* Expose ` createApplication() ` .
* /
exports = module . exports = createApplication ;
/ * *
* Create an express application .
*
* @ return { Function }
* @ api public
* /
function createApplication ( ) {
2016-02-12 13:10:16 +00:00
var app = function ( req , res , next ) {
app . handle ( req , res , next ) ;
} ;
mixin ( app , EventEmitter . prototype , false ) ;
mixin ( app , proto , false ) ;
2015-07-20 13:42:07 +00:00
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 ;
2016-02-12 13:10:16 +00:00
/ * *
* Expose middleware
* /
exports . query = require ( './middleware/query' ) ;
exports . static = require ( 'serve-static' ) ;
2015-07-20 13:42:07 +00:00
2016-02-12 13:10:16 +00:00
/ * *
* Replace removed middleware with an appropriate error message .
* /
2015-07-20 13:42:07 +00:00
2016-02-12 13:10:16 +00:00
[
'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
} ) ;
} ) ;