forked from JscramblerBlog/express-mongoose-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (22 loc) · 794 Bytes
/
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
const express = require('express'),
mongoose = require('mongoose'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
methodOverride = require('method-override'),
cors = require('cors'),
app = express();
const env = process.env.NODE_ENV = process.env.NODE_ENV || 'development',
envConfig = require('./server/env')[env];
require('./database');
// hack to use async-await in controllers
require('express-async-errors');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
app.use(methodOverride());
app.use(cookieParser());
app.use(express.static(__dirname + '/public'));
require('./server/routes')(app);
app.listen(envConfig.port, function(){
console.log('Server listening on port ' + envConfig.port)
});