-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (40 loc) 路 1.21 KB
/
Copy pathindex.js
File metadata and controls
43 lines (40 loc) 路 1.21 KB
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
42
43
require("dotenv").config();
const express = require("express");
const app = express();
const displayRoutes = require("express-routemap");
const port = process.env.APP_PORT || 3000;
const sequelize = require("./config/sequelize");
const customerRoutes = require("./routes/customer.routes");
const todoRoutes = require("./routes/todos.routes");
const otpModel = require("./models/otp.model");
app.use(express.json());
app.use(customerRoutes);
app.use(todoRoutes);
app.get("/", (req, res) => {
res.status(200).json({
status: "success",
message: "Proudly 馃嚦馃嚞",
});
});
try {
(async () => {
await sequelize.authenticate();
// await sequelize.sync({force:true});
console.log("Connection has been established successfully.");
app.listen(port, () => {
displayRoutes(app);
console.log(`Example app listening on port ${port}`);
});
})();
// sequelize.authenticate()
// .then(() => {
// console.log('Connection has been established successfully.');
// app.listen(port, () => {
// displayRoutes(app)
// console.log(`Example app listening on port ${port}`)
// })
// })
} catch (error) {
console.error("Unable to connect to the database:", error);
process.exit(1);
}