-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (30 loc) · 944 Bytes
/
app.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
require('dotenv').config()
const express = require('express')
const mongoose = require('mongoose')
const routes = require('./routes/loger_routes')
var bodyParser = require('body-parser')
const app = express()
app.set('port', (process.env.PORT || 5000))
app.use(express.urlencoded({ extended: true }))
app.use(bodyParser.urlencoded())
app.use(bodyParser.json())
app.use(routes)
async function start() {
const env = process.env
const dbLink = `${env.dbLogin}:${env.dbPassword}${env.clusterName}/${env.dbName}`
try {
await mongoose.connect(
`mongodb+srv://${dbLink}?retryWrites=true&w=majority&ssl=true`,
{
useNewUrlParser: true,
useFindAndModify: false
}
)
app.listen(app.get('port'), () => {
console.log(`Logger started on http://localhost:${app.get('port')}`)
})
} catch (e) {
console.log(e)
}
}
start()