import express from 'express';
import dotenv from 'dotenv';
import authRoutes from './routes/authRoutes.js'
dotenv.config();
import cors from 'cors';


import sparePartRoutes from './routes/sparePartRoutes.js';
import stockOutRoutes from './routes/stockOutRoutes.js';
import stockInRoutes from './routes/stockInRoutes.js';
import reportRoutes from './routes/reportRoutes.js'
import { connectDB } from './config/db.js';

const PORT = process.env.PORT || 5000;

const app = express();

app.use(cors({
    origin:"http://localhost:5174",
    credentials:true
}));


app.use(express.json());

app.use('/api/user',authRoutes);
app.use('/api/spareparts', sparePartRoutes);
app.use('/api/stockout', stockOutRoutes);
app.use('/api/stockin', stockInRoutes);
app.use('/api/report',reportRoutes);



connectDB();

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