-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.js
37 lines (32 loc) · 920 Bytes
/
entry.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
34
35
36
37
'use strict'
// Read .env file.
require('dotenv').config()
const async = require('async')
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const dbHelper = require('./utils/dbHelper')
const PGConfig = require('./config/database')('PG', process.env.NODE_ENV)
const pgConnection = new (dbHelper)(PGConfig)
const MongoConfig = require('./config/database')('MONGO', process.env.NODE_ENV)
const mongoConnection = new (dbHelper)(MongoConfig)
/**
* This is required in all environments since this is what mongoose uses to establish connection to the required DB instances.
*/
async.parallel([
function (cb) {
pgConnection.establishConnection((err) => {
if (err) return cb(err)
cb()
})
},
function (cb) {
mongoConnection.establishConnection((err) => {
if (err) return cb(err)
cb()
})
}
],
function (err) {
if (err) throw err
require('./server')
}
)