-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (33 loc) · 830 Bytes
/
server.js
File metadata and controls
38 lines (33 loc) · 830 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
// require('dotenv').config();
//servere.js
const app = require('./app');
const PORT = process.env.PORT || 5000;
const startServer = (port) => {
app.listen(port, () => {
console.log(`Server running on port ${port}`);
}).on('error', (err) => {
if (err.code === 'EADDRINUSE') {
console.warn(`Port ${port} is in use, trying another port...`);
startServer(port + 1);
} else {
throw err;
}
});
};
startServer(PORT);
/*
Backend Structure
backend/
├── config/
│ └── db.js
├── controllers/
│ └── superUserController.js
├── middlewares/
│ └── authMiddleware.js
├── models/
│ └── superUserModel.js
├── routes/
│ └── superUserRoutes.js
├── app.js
└── server.js
*/