const express = require('express');
const cors = require('cors');

const connectDB = require('./config/db');

const authRoutes = require('./routes/authRoutes');

const productRoutes = require('./routes/productRoutes');
const SupplierRoutes = require('./routes/SupplierRoutes');
const shipmentRoutes = require('./routes/shipmentRoutes');
const deliveryRoutes = require('./routes/deliveryRoutes');
const reportsRoutes = require('./routes/reportsRoutes');
const protectedRoutes = require('./routes/protectedRoutes');

const app = express();

app.use(cors());
app.use(express.json());
connectDB();

app.use('/api/product', productRoutes);
app.use('/api/supplier', SupplierRoutes);
app.use('/api/auth', authRoutes);

app.use('/api/shipment', shipmentRoutes);
app.use('/api/delivery', deliveryRoutes);
app.use('/api/reports', reportsRoutes);
app.use('/api/protected', protectedRoutes);

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


