const express = require('express');
const cors = require('cors');
const connectDB = require('./config/db');
const authRoutes = require('./routes/authRoutes');
const itemRoutes = require('./routes/itemRoutes');
const healthRoutes = require('./routes/healthRoutes');
const notFound = require('./middleware/errorHandler').notFound;
const errorHandler = require('./middleware/errorHandler').errorHandler;

const app = express();

app.use(cors());
app.use(express.json());
connectDB();
app.use('/api/health', healthRoutes);
app.use('/api/auth', authRoutes);
app.use('/api/items', itemRoutes);

app.use(notFound);
app.use(errorHandler);

const PORT=5000;


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


