-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (21 loc) · 806 Bytes
/
index.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 mongoose = require('mongoose');
require('dotenv').load({ path: '.env' });
mongoose.Promise = global.Promise;
// load the right config if in production
if (process.env.MODE == "production") {
mongoose.connect(process.env.MONGODB_URI);
} else {
mongoose.connect(process.env.LOCAL_MONGO_URI);
}
mongoose.connection.on('error', async (err) => {
console.error(err);
console.log('%s MongoDB connection error. Please make sure MongoDB is running.');
process.exit();
});
// just to restart app o
// Start our app!
const app = require('./app');
app.set('port', process.env.PORT || 7777);
const server = app.listen(app.get('port'), () => {
console.log(`Main server running on port ${server.address().port}`)
});