-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) Β· 821 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (22 loc) Β· 821 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
require('dotenv').config();
const app = require('./src/app');
const connectDB = require('./src/config/database');
const PORT = process.env.PORT || 3000;
// Connect to MongoDB
connectDB();
// Start server
const server = app.listen(PORT, () => {
console.log(`π Server running on http://localhost:${PORT}`);
console.log(`π‘ API available at http://localhost:${PORT}/api`);
console.log(`π Environment: ${process.env.NODE_ENV || 'development'}`);
});
// Handle unhandled promise rejections
process.on('unhandledRejection', (err) => {
console.error(`β Unhandled Rejection: ${err.message}`);
server.close(() => process.exit(1));
});
// Handle uncaught exceptions
process.on('uncaughtException', (err) => {
console.error(`β Uncaught Exception: ${err.message}`);
process.exit(1);
});