-
Notifications
You must be signed in to change notification settings - Fork 55
/
server.js
37 lines (31 loc) · 1.01 KB
/
server.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
var express = require('express'),
bodyParser = require('body-parser'),
methodOverride = require('method-override'),
errorHandler = require('errorhandler'),
morgan = require('morgan'),
routes = require('./backend'),
api = require('./backend/api');
var app = module.exports = express();
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(express.static(__dirname + '/'));
app.use('/build', express.static('public'));
var env = process.env.NODE_ENV;
if ('development' == env) {
app.use(errorHandler({
dumpExceptions: true,
showStack: true
}));
}
if ('production' == app.get('env')) {
app.use(errorHandler());
}
app.get('/', routes.index);
app.all('/api/events', api.events);
app.all('/api/events/:eventId', api.event)
app.listen(8080);
console.log('Magic happens on port 8080...');