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

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

const authRoutes = require('./routes/authRoutes');
const borrowRoutes = require('./routes/borrowRoutes')
const bookRoutes = require('./routes/bookRoutes')
const studentRoutes = require('./routes/studentRoutes')
const searchRoutes = require('./routes/searchRoutes')
const statsRoutes = require('./routes/statsRoutes')
const protectedRoutes = require('./routes/protectedRoutes')


const app = express();

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

app.use('/api/book', bookRoutes);
app.use('/api/student', studentRoutes)
app.use('/api/auth/', authRoutes)
app.use('/api/borrow',borrowRoutes)
app.use('/api/search', searchRoutes)
app.use('/api/stats', statsRoutes)
app.use('/api/protected', protectedRoutes)


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

