const express = require('express');
const cors = require('cors');
const { connectDB } = require('./utils/db');
const userRoutes = require('./routes/userRoutes');
const authRoutes = require('./routes/authRoutes');
const roleRoutes = require('./routes/roleRoutes');
const projectRoutes = require('./routes/projectRoutes');
const productRoutes = require('./routes/productRoutes')
const productImportRoutes = require('./routes/productImportRoutes'); 
const borrowtransactionRoutes = require('./routes/borrowtransactionRoutes');
const positionRoutes = require('./routes/positionRoutes')
const app = express();

app.use(cors({
    origin: 'http://localhost:4200', 
    methods: ['GET', 'POST', 'PUT', 'DELETE'], 
    allowedHeaders: ['Content-Type', 'Authorization'] 
}));

app.use(express.json());
app.use('/api/member', userRoutes);
app.use('/api/role', roleRoutes);
app.use('/api/auth', authRoutes);
app.use('/api/project', projectRoutes);
app.use('/api/product', productRoutes);
app.use('/api/borrow_transaction',borrowtransactionRoutes);
app.use('/api/positions', positionRoutes);



connectDB();

module.exports = app;