-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (23 loc) · 779 Bytes
/
server.js
File metadata and controls
28 lines (23 loc) · 779 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
const app = require('./app.js')
const dotenv = require('dotenv')
const connectDatabase = require('./config/database.js')
// Handling Uncaught Exception
process.on("uncaughtException", (err) => {
console.log(`Error: ${err.message}`)
console.log(`Shutting down the server due to Uncaught Exception`)
})
// Config - load env file in development
if (process.env.NODE_ENV !== 'production') {
dotenv.config({ path: "./backend/config/config.env" });
}
// Connecting to the database
connectDatabase();
// For local development only
if (process.env.NODE_ENV !== 'production') {
const PORT = process.env.PORT || 7000;
app.listen(PORT, () => {
console.log(`Server is working on http://localhost:${PORT}`);
})
}
// Export for Vercel
module.exports = app;