import mongoose from "mongoose"
import cookieParser from "cookie-parser"
import express from "express"
import cors from "cors"
import connectDb from "./configs/db.js"
import dotenv from "dotenv"
dotenv.config()

import authRouter from "./routes/auth.route.js"
import studentRouter from "./routes/student.route.js"
import paymentRouter from "./routes/payment.route.js"
import reportRouter from "./routes/report.route.js"

let port = process.env.PORT
let app = express()

app.use(express.json())
app.use(cookieParser())
app.use(cors({
  origin: "http://localhost:5173",
  credentials: true
}))

app.use("/api/auth", authRouter)
app.use("/api/student", studentRouter)
app.use("/api/payment", paymentRouter)
app.use("/api/report", reportRouter)

app.listen(port, () => {
    console.log(`app running at port ${port}`)
    connectDb()
})