import express from "express";
import adminRoutes from "./routes/adminRoutes";
import userRoutes from "./routes/userRoutes";
import billingRoutes from "./routes/billingRoutes";
import tradeDataRoutes from "./routes/tradeDataRoutes";
import notificationsRoutes from "./routes/notificationsRoutes";
import supportRoutes from "./routes/supportRoutes";
import settingsRoutes from "./routes/settingsRoutes";
import { errorHandler } from "./middleware/errorHandler";
import { auth } from "./middleware/auth";

const app = express();

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

// Routes
app.use("/api/admin", adminRoutes);
app.use("/api/users", userRoutes);
app.use("/api/billing", billingRoutes);
app.use("/api/trades", tradeDataRoutes);
app.use("/api/notifications", notificationsRoutes);
app.use("/api/support", supportRoutes);
app.use("/api/settings", settingsRoutes);

// Error handling middleware
app.use(errorHandler);

const PORT = process.env.PORT || 3001;

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