-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (28 loc) · 784 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
28
29
30
const express = require('express');
const bodyParser = require('body-parser');
const app = module.exports = express();
const config = require('./config/config');
const mongoose = require('mongoose');
app.use(express.static(__dirname + '/public_html', {
maxAge: 86400000
}));
mongoose.Promise = global.Promise;
let promise = mongoose.connect(config.db, {
useMongoClient: true
})
console.log(config.db);
promise = promise.then((db) => {
console.log("mongo connection started on : ", config.db)
setupApp();
})
promise.catch(e => {
console.log(e);
process.exit(1);
})
app.use(bodyParser.json());
function setupApp() {
require('./routes/routes')(app);
app.listen(process.env.PORT || '8088', () => {
console.log("sevrer started on 8088");
});
}