import express from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import connectDB from './config/db';

import authRoutes from './routes/authRoutes';
import posRoutes from './routes/posRoutes'; // Import POS routes
import paymentRoutes from './routes/paymentRoutes'; // Import Payment routes

dotenv.config();

const app = express();
const PORT = process.env.PORT || 5000;

// Connect to Database
connectDB();

// Middleware
app.use(cors());
app.use(express.json());

// Routes
app.use('/api/auth', authRoutes);
app.use('/api/pos', posRoutes); // Mount POS routes
app.use('/api/payment', paymentRoutes); // Mount Payment routes

// Basic Route
app.get('/', (req, res) => {
    res.send('Dine360 API is running...');
});

// Start Server
app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});
