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


const app = express();
connectDB();
app.set('trust proxy', true);

// Change your routes to look like this:
app.use('/email-anomaly-system/dashboard', require('./routes/dashboard'));
app.use('/email-anomaly-system/track', require('./routes/track'));

// And change your home route to this:
app.get('/email-anomaly-system', (req, res) => {
    res.send("System Running");
});

// IMPORTANT: Passenger manages the port automatically
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Server running on port ${PORT}`);
});