-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (29 loc) · 850 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
29
30
31
32
33
34
35
36
37
38
const app = require('./server.js')
const mongodb = require('mongodb')
const dotenv = require('dotenv')
const UserDAO = require('./dao/userDAO')
const ApplicationsDAO = require('./dao/applicationsDAO')
dotenv.config()
const MongoClient = mongodb.MongoClient
const port = process.env.PORT
const connect = () => {
MongoClient.connect(process.env.TLD_DB_URI,
{
poolSize: 20,
wtimeout: 5000,
useNewUrlParser: true
})
.catch(err => {
console.error(err)
process.exit(1)
})
.then(async client => {
await ApplicationsDAO.injectDB(client)
await UserDAO.injectDB(client)
app.listen(port, () => {
console.log(`Listening on port ${port}`);
})
})
}
connect()
module.exports = app