-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (40 loc) · 1.28 KB
/
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
42
43
44
45
46
47
const express = require("express");
require("dotenv").config(); // Load environment variables
const sequelize = require("./db"); // Import Sequelize instance
const cors = require("cors");
// Routers (uncomment and add routes when ready)
// const Doctors_Routes = require("./routes/Doctors_Routes");
// const QR_Routes = require("./routes/QR_Routes");
// const AdminControl = require("./routes/Admin_Routes");
const app = express();
// Middleware
app.use(express.json()); // Parse JSON request bodies
app.use(cors()); // Enable CORS for cross-origin requests
// Base Route
app.get("/", (req, res) => {
res.json({
msg: "LIVE",
});
});
// Uncomment when routes are available
// app.use("/api/doctor", Doctors_Routes);
// app.use("/api/qrcode", QR_Routes);
// app.use("/api/admin", AdminControl);
// Test database connection and sync models
sequelize
.authenticate()
.then(() => {
console.log("Database connection established.");
return sequelize.sync({ force: false }); // Sync models without dropping tables
})
.then(() => {
console.log("Database synced.");
})
.catch((err) => {
console.error("Database connection failed:", err);
});
// Start the server
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});