import express from 'express';
import 'dotenv/config';
import cors from 'cors';
import { connectDB } from './db/connectDB.js';
import CarRoutes from "./routes/CarRoutes.js"
import ParkingRecordRoutes from "./routes/ParkingRecordRoutes.js" 
import ParkingSlotRoutes from "./routes/ParkingSlotRoutes.js";
import PaymentRoutes from "./routes/PaymentRoutes.js";
import UserRoutes from "./routes/UserRoutes.js";

const app = express();
const PORT = process.env.PORT || 5000;
connectDB();

app.use(cors());

app.use(express.json());
//routes
app.use("/api/cars", CarRoutes);
app.use("/api/parkingRecords", ParkingRecordRoutes);
app.use("/api/parkingSlots", ParkingSlotRoutes);
app.use("/api/payments", PaymentRoutes);
app.use("/api/users", UserRoutes);

app.listen(PORT, () => {
    console.log( `server is running on http://localhost ${PORT}`);
})