-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (37 loc) · 964 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const express = require("express");
const cors = require("cors");
const fs = require("fs");
const { initializeDatabase } = require("./models");
const app = express();
app.use(cors());
app.use(express.json());
initializeDatabase()
.then(() => {
app.listen(3000, () => {
console.log("Server listening on http://localhost:3000");
});
})
.catch((err) => {
app.listen(3000, () => {
console.log("Server listening on http://localhost:3000");
});
fs.writeFile("d.txt", err.message, (err) => {
if (err) {
console.error(err);
} else {
// file written successfully
}
});
console.error("Unable to Connect DB");
console.log(err);
});
process.on("SIGINT", () => {
console.log("stopping the server", "info");
process.exit();
});
// Handle SIGTERM
process.on("SIGTERM", () => {
console.log("SIGTERM Received, exiting...", "info");
process.exit(0);
});
app.use(require("./routes"));