-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
27 lines (21 loc) · 873 Bytes
/
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
var express = require('express');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var morgan = require('morgan');
var cors = require('cors');
var middleware = require('./source/middleware');
var logger = require('./source/utils/logger');
var app = express();
var env = process.env.NODE_ENV || 'development';
var port = process.env.PORT || 3010;
morgan.format('custom', ':method :url :req[content-type] :req[content-length] HTTP/:http-version :status :res[content-length] - :response-time ms');
app.use(morgan('custom', {stream: logger.stream()}));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(cors());
app.use(express.static(__dirname + '/public'));
require('./source/api')(app);
app.use(middleware.errors());
app.listen(port, function () {
logger.info('app listening on port ' + port + ' ' + env);
});