import express from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import dbConnect from './configs/db.js';

import authRouter from './routes/auth.route.js';
import cookieParser from 'cookie-parser';
import taskRouter from './routes/task.route.js';

dotenv.config()
const port = process.env.PORT
const app = express()


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

app.use("/api/auth", authRouter)
app.use("/api/task", taskRouter)
app.listen(port, () => {
    console.log(`server is running at port ${port}`)
    dbConnect()
})
