[484] | 1 | /** |
---|
| 2 | * Module dependencies. |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | var connect = require('connect') |
---|
| 6 | , proto = require('./application') |
---|
| 7 | , Route = require('./router/route') |
---|
| 8 | , Router = require('./router') |
---|
| 9 | , req = require('./request') |
---|
| 10 | , res = require('./response') |
---|
| 11 | , utils = connect.utils; |
---|
| 12 | |
---|
| 13 | /** |
---|
| 14 | * Expose `createApplication()`. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | exports = module.exports = createApplication; |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | * Framework version. |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | exports.version = '3.2.5'; |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * Expose mime. |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | exports.mime = connect.mime; |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * Create an express application. |
---|
| 33 | * |
---|
| 34 | * @return {Function} |
---|
| 35 | * @api public |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | function createApplication() { |
---|
| 39 | var app = connect(); |
---|
| 40 | utils.merge(app, proto); |
---|
| 41 | app.request = { __proto__: req }; |
---|
| 42 | app.response = { __proto__: res }; |
---|
| 43 | app.init(); |
---|
| 44 | return app; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * Expose connect.middleware as express.* |
---|
| 49 | * for example `express.logger` etc. |
---|
| 50 | */ |
---|
| 51 | |
---|
| 52 | for (var key in connect.middleware) { |
---|
| 53 | Object.defineProperty( |
---|
| 54 | exports |
---|
| 55 | , key |
---|
| 56 | , Object.getOwnPropertyDescriptor(connect.middleware, key)); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * Error on createServer(). |
---|
| 61 | */ |
---|
| 62 | |
---|
| 63 | exports.createServer = function(){ |
---|
| 64 | console.warn('Warning: express.createServer() is deprecated, express'); |
---|
| 65 | console.warn('applications no longer inherit from http.Server,'); |
---|
| 66 | console.warn('please use:'); |
---|
| 67 | console.warn(''); |
---|
| 68 | console.warn(' var express = require("express");'); |
---|
| 69 | console.warn(' var app = express();'); |
---|
| 70 | console.warn(''); |
---|
| 71 | return createApplication(); |
---|
| 72 | }; |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | * Expose the prototypes. |
---|
| 76 | */ |
---|
| 77 | |
---|
| 78 | exports.application = proto; |
---|
| 79 | exports.request = req; |
---|
| 80 | exports.response = res; |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * Expose constructors. |
---|
| 84 | */ |
---|
| 85 | |
---|
| 86 | exports.Route = Route; |
---|
| 87 | exports.Router = Router; |
---|
| 88 | |
---|
| 89 | // Error handler title |
---|
| 90 | |
---|
| 91 | exports.errorHandler.title = 'Express'; |
---|
| 92 | |
---|