-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfig.js
52 lines (47 loc) · 1.38 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function() {
var config, express, util;
express = require('express');
util = require('util');
config = function(app) {
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon(__dirname + '/public/favicon.ico'));
app.use(express.logger('dev'));
app.use(function(req, res, next) {
var data, length,
_this = this;
app.host = util.format('http://%s/', req.headers['host']);
data = [];
length = 0;
req.on('data', function(chunk) {
length += chunk.length;
data.push(chunk);
});
return req.on('end', function() {
req.rawBody = Buffer.concat(data, length);
next();
});
});
app.use(app.router);
app.use(express.urlencoded());
app.use(express.json());
app.use(express.methodOverride());
app.use(require('less-middleware')({
src: __dirname + '/public'
}));
app.use(express.compress());
if (process.env.NODE_ENV === 'production') {
app.use(express["static"](__dirname + '/public', {
maxAge: 86400000
}));
} else {
app.use(express["static"](__dirname + '/public'));
}
app.locals.pretty = true;
if ('development' === app.get('env')) {
return app.use(express.errorHandler());
}
};
module.exports = config;
}).call(this);