-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·31 lines (26 loc) · 778 Bytes
/
server.js
File metadata and controls
executable file
·31 lines (26 loc) · 778 Bytes
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
process.on('uncaughtException', err => {
console.log(err)
console.log('Uncaught Exception! Shutting Down!')
process.exit(1)
})
const dotenv = require('dotenv')
dotenv.config({ path: './config.env' })
const mongoose = require('mongoose')
mongoose.connect(process.env.MONGODB_CONNECT, {
useNewUrlParser: true
})
.then(data => console.log("Database connected successfully."))
.catch(err => console.log(err))
const app = require('./app')
const port = process.env.PORT || 3000
const server = app.listen(port, () => {
console.log(`Listening on port ${port}`)
})
process.on('unhandledRejection', err => {
console.log(err)
console.log('Unhandled rejection! Shutting Down!')
process.exit(1)
server.close(() => {
process.exit(1)
})
})