-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 744 Bytes
/
server.js
File metadata and controls
24 lines (19 loc) · 744 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
const app = require("./app"); // Import the app
const logger = require("./utils/logger");
const connectDB = require("./config/db");
const dotenv = require("dotenv");
dotenv.config();
const PORT = process.env.PORT || 5000;
connectDB();
app.listen(PORT, () => {
logger.info(`Server running on: http://localhost:${PORT}`);
});
// Global error handlers for uncaught exceptions and unhandled promise rejections
process.on("unhandledRejection", (err) => {
logger.error(`Unhandled Rejection: ${err.message}`, err);
process.exit(1); // Exit on unhandled promise rejection
});
process.on("uncaughtException", (err) => {
logger.error(`Uncaught Exception: ${err.message}`, err);
process.exit(1); // Exit on uncaught exception
});