-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (31 loc) · 825 Bytes
/
Copy pathserver.js
File metadata and controls
40 lines (31 loc) · 825 Bytes
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
38
39
40
'use strict';
let express = require('express');
let mongoose = require('mongoose');
let bodyParser = require('body-parser');
let Q = require('q');
mongoose.Promise = Q.Promise;
let path = require('path');
let connectDomain = require('connect-domain');
let app = express();
let config;
if (app.get('env') === 'development') {
config = require('./config');
} else {
config = require('./config-prod');
}
mongoose.connect(config.database);
process.on('SIGINT', function() {
mongoose.connection.close(function () {
process.exit(0);
});
});
app.use(connectDomain());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
// api secret
app.set('olegSecret', config.token.secret);
app.use("/", express.static(path.join(__dirname, 'public')));
// start server
app.listen(config.port);