-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (30 loc) · 1 KB
/
app.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
var express = require('express');
var routes = require('./routes');
var logger = require('morgan');
var bodyParser = require('body-parser');
var errorhandler = require('errorhandler');
var http = require('http');
var path = require('path');
var app = express();
try {
app.locals.build = require('./public/build/build-info.json');
} catch (err) {
app.locals.build = { revision: new Date().toISOString() };
}
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pejs');
app.disable('x-powered-by');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.get('/', routes.index);
app.use(express.static(path.join(__dirname, 'public')));
// TODO: add error handler
// development only
if ('development' === app.get('env')) {
app.use(errorhandler());
}
http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});