-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (28 loc) · 1012 Bytes
/
server.js
File metadata and controls
47 lines (28 loc) · 1012 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// import process from 'node:process';
const process = require('node:process');
const app = require('./app');
const dotenv = require('dotenv');
const connectDatabase = require("./config/database");
// Handing Uncaught Exception
process.on('uncaughtException', function (err) {
console.log(`Error: ${err.message}`);
console.log("Shutting Down the Server due to Handing Uncaught Exception");
server.close(()=>{
process.exit(1);
})
})
// //Config
dotenv.config({path:"config/config.env"});
// // Connecting to database
connectDatabase();
const server = app.listen(process.env.PORT, ()=>{
console.log(`Server is running on http://localhost${process.env.PORT}`);
});
// // Unhandled Promise Rejection
process.on('uncaughtException', function (err) {
console.log(`Error: ${err.message}`);
console.log("Shutting Down the Server due to Unhandled Promise Rejection");
server.close(()=>{
process.exit(1);
})
})