Mercurial > hg > nodescore
comparison node_modules/express/lib/express.js @ 73:0c3a2942ddee
now using express to server static content
author | Rob Canning <rc@kiben.net> |
---|---|
date | Sun, 29 Jun 2014 12:11:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
72:9af4250ff7d5 | 73:0c3a2942ddee |
---|---|
1 /** | |
2 * Module dependencies. | |
3 */ | |
4 | |
5 var EventEmitter = require('events').EventEmitter; | |
6 var mixin = require('utils-merge'); | |
7 var proto = require('./application'); | |
8 var Route = require('./router/route'); | |
9 var Router = require('./router'); | |
10 var req = require('./request'); | |
11 var res = require('./response'); | |
12 | |
13 /** | |
14 * Expose `createApplication()`. | |
15 */ | |
16 | |
17 exports = module.exports = createApplication; | |
18 | |
19 /** | |
20 * Create an express application. | |
21 * | |
22 * @return {Function} | |
23 * @api public | |
24 */ | |
25 | |
26 function createApplication() { | |
27 var app = function(req, res, next) { | |
28 app.handle(req, res, next); | |
29 }; | |
30 | |
31 mixin(app, proto); | |
32 mixin(app, EventEmitter.prototype); | |
33 | |
34 app.request = { __proto__: req, app: app }; | |
35 app.response = { __proto__: res, app: app }; | |
36 app.init(); | |
37 return app; | |
38 } | |
39 | |
40 /** | |
41 * Expose the prototypes. | |
42 */ | |
43 | |
44 exports.application = proto; | |
45 exports.request = req; | |
46 exports.response = res; | |
47 | |
48 /** | |
49 * Expose constructors. | |
50 */ | |
51 | |
52 exports.Route = Route; | |
53 exports.Router = Router; | |
54 | |
55 /** | |
56 * Expose middleware | |
57 */ | |
58 | |
59 exports.query = require('./middleware/query'); | |
60 exports.static = require('serve-static'); | |
61 | |
62 /** | |
63 * Replace removed middleware with an appropriate error message. | |
64 */ | |
65 | |
66 [ | |
67 'json', | |
68 'urlencoded', | |
69 'bodyParser', | |
70 'compress', | |
71 'cookieSession', | |
72 'session', | |
73 'logger', | |
74 'cookieParser', | |
75 'favicon', | |
76 'responseTime', | |
77 'errorHandler', | |
78 'timeout', | |
79 'methodOverride', | |
80 'vhost', | |
81 'csrf', | |
82 'directory', | |
83 'limit', | |
84 'multipart', | |
85 'staticCache', | |
86 ].forEach(function (name) { | |
87 Object.defineProperty(exports, name, { | |
88 get: function () { | |
89 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.'); | |
90 }, | |
91 configurable: true | |
92 }); | |
93 }); |