-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (22 loc) · 792 Bytes
/
app.js
File metadata and controls
30 lines (22 loc) · 792 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
import dotenv from "dotenv";
dotenv.config();
import express from "express";
import DatabaseConnection from "./config/database.js";
import Kernel from "./app/Http/Kernel.js"; // Import the Kernel class
// application initialization
const app = express();
const mongoUri = process.env.MONGO_URI;
// Instantiate the database connection service
const dbConnection = new DatabaseConnection(mongoUri);
dbConnection.connect();
const kernel = new Kernel(app); // Instantiate Kernel with the app
kernel.configureApplication(); // Apply all configured middleware
const port = process.env.PORT;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
// Handle graceful shutdown
process.on("SIGINT", async () => {
await dbConnection.disconnect();
process.exit(0);
});