import dotenv from "dotenv"
dotenv.config()
import express from "express";
import cookieParser from "cookie-parser";
import cors from "cors";
import { connection } from "./configs/db.js";
import initializeDb from "./configs/initdb.js";

import authRouter from "./routes/auth.route.js";
import patientRouter from "./routes/patient.route.js";
import appointmentRouter from "./routes/appointment.route.js";
import medicalReport from "./routes/medical.report.route.js";
import reportRouter from "./routes/overall.report.route.js";

const app = express()   
const port = process.env.PORT || 3000
app.use(express.json());
app.use(cookieParser());
app.use(cors({
    origin: "http://localhost:5173",
    credentials: true
}));

app.use("/api/auth", authRouter);
app.use("/api/patient", patientRouter);
app.use("/api/appointment", appointmentRouter);
app.use("/api/medical-report", medicalReport);
app.use("/api/report", reportRouter);

app.listen(port, () => {
    console.log(`Server is running on port ${port}`);
    initializeDb()
})