-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (19 loc) · 846 Bytes
/
index.js
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
import express from 'express';
import './env/env.js';
import { connect2DB, logger, setEnvironmentConfig } from './src/configurations/index.js';
import { useMiddlewares } from './src/middlewares/index.js';
import routes from './src/routes/index.js';
const main = () => {
setEnvironmentConfig(); // Set environment configurations.
const app = express();
useMiddlewares(app); // use many built-in middlewares
routes(app); // Add routes
connect2DB(); // Connect to the database
// Start the server for listening on a port and export it for testing purposes.
const server = app.listen(process.env.PORT, () => {
logger.info(`App server is listening on port: ${process.env.PORT} for ${process.env.NODE_ENV}`);
});
return server; // Export the server for testing purposes
};
main();
export default main;