-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 691 Bytes
/
server.js
File metadata and controls
26 lines (21 loc) · 691 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
require('dotenv').config();
const app = require('./app');
const db_connection = require('./config/db');
process.on('uncaughtException', (err) => {
console.log('Uncaught Exception! Shutting down...');
console.log(err.name, err.message);
process.exit(1);
});
const DB = `${process.env.DB_URI}/${process.env.DATABASE}`;
const PORT = process.env.PORT || 3000;
const server = app.listen(PORT, async () => {
const dbCheck = await db_connection(DB);
console.log(`App running on port ${PORT} ${dbCheck}`);
});
process.on('unhandledRejection', (err) => {
console.log('Unhandled Rejection! Shutting down...');
console.log(err);
server.close(() => {
process.exit(1);
});
});