2015-07-20 13:42:07 +00:00
|
|
|
/**
|
|
|
|
* Module dependencies.
|
|
|
|
*/
|
|
|
|
|
2015-08-14 19:58:05 +00:00
|
|
|
var deprecate = require('depd')('express');
|
2015-07-20 13:42:07 +00:00
|
|
|
var mixin = require('merge-descriptors');
|
2015-08-14 19:58:05 +00:00
|
|
|
var merge = require('utils-merge');
|
|
|
|
var connect = require('connect')
|
|
|
|
, proto = require('./application')
|
|
|
|
, Route = require('./router/route')
|
|
|
|
, Router = require('./router')
|
|
|
|
, req = require('./request')
|
|
|
|
, res = require('./response');
|
2015-07-20 13:42:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose `createApplication()`.
|
|
|
|
*/
|
|
|
|
|
|
|
|
exports = module.exports = createApplication;
|
|
|
|
|
2015-08-14 19:58:05 +00:00
|
|
|
/**
|
|
|
|
* Expose mime.
|
|
|
|
*/
|
|
|
|
|
|
|
|
exports.mime = connect.mime;
|
|
|
|
|
2015-07-20 13:42:07 +00:00
|
|
|
/**
|
|
|
|
* Create an express application.
|
|
|
|
*
|
|
|
|
* @return {Function}
|
|
|
|
* @api public
|
|
|
|
*/
|
|
|
|
|
|
|
|
function createApplication() {
|
2015-08-14 19:58:05 +00:00
|
|
|
var app = connect();
|
|
|
|
merge(app, proto);
|
2015-07-20 13:42:07 +00:00
|
|
|
app.request = { __proto__: req, app: app };
|
|
|
|
app.response = { __proto__: res, app: app };
|
|
|
|
app.init();
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
2015-08-14 19:58:05 +00:00
|
|
|
/**
|
|
|
|
* Expose connect.middleware as express.*
|
|
|
|
* for example `express.logger` etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mixin(exports, connect.middleware);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deprecated createServer().
|
|
|
|
*/
|
|
|
|
|
|
|
|
exports.createServer = deprecate.function(createApplication,
|
|
|
|
'createServer() is deprecated\n' +
|
|
|
|
'express applications no longer inherit from http.Server\n' +
|
|
|
|
'please use:\n' +
|
|
|
|
'\n' +
|
|
|
|
' var express = require("express");\n' +
|
|
|
|
' var app = express();\n' +
|
|
|
|
'\n'
|
|
|
|
);
|
|
|
|
|
2015-07-20 13:42:07 +00:00
|
|
|
/**
|
|
|
|
* Expose the prototypes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
exports.application = proto;
|
|
|
|
exports.request = req;
|
|
|
|
exports.response = res;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose constructors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
exports.Route = Route;
|
|
|
|
exports.Router = Router;
|
|
|
|
|
2015-08-14 19:58:05 +00:00
|
|
|
// Error handler title
|
2015-07-20 13:42:07 +00:00
|
|
|
|
2015-08-14 19:58:05 +00:00
|
|
|
exports.errorHandler.title = 'Express';
|
2015-07-20 13:42:07 +00:00
|
|
|
|