-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
34 lines (26 loc) · 848 Bytes
/
index.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
'use strict';
var express = require('express');
var morgan = require('morgan');
var cors = require('cors');
var bodyParser = require('body-parser');
var app = express();
if(app.get('env') != 'development') {
require('newrelic');
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cors({credentials: true, origin: true}));
morgan.token('body', function(req) {
return JSON.stringify(req.body);
});
app.use(morgan(':method :url :status :response-time ms - :res[content-length] :body'));
require('./routes/invite')(app);
require('./routes/members')(app);
require('./routes/feeds')(app);
require('./routes/membership')(app);
app.use(function(err, req, res, next) {
/*jshint unused:false*/
console.error(err);
res.status(500).send('Internal server error');
});
app.listen(process.env.PORT || 9000);