-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (28 loc) · 841 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
29
30
31
32
33
import mongoose from 'mongoose';
import app from './index';
import config from './api/config/config';
const debug = require('debug')('app:startup');
const dbDebug = require('debug')('app:db');
if (process.env.NODE_ENV === 'test') {
mongoose.connect(config.test_db, {
useNewUrlParser: true,
});
app.listen(config.test_port, (err) => {
if (err) throw err;
debug(`App listening on port ${config.test_port}`);
});
} else {
mongoose.connect(config.db, {
useNewUrlParser: true,
});
app.listen(config.port, (err) => {
if (err) throw err;
debug(`App listening on port ${config.port}`);
});
}
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.connection.on('connected', () => {
dbDebug(`mongoose default connection open to ${config.db}`);
});
module.exports = app;