import express from "express";
import authRoutes from "./authRoutes.js";
import swiTablesRoutes from "./swiTablesRoutes.js";
import swiAssignmentRoutes from "./swiAssignmentRoutes.js";
import ticketsRoutes from "./ticketsRoutes.js";
import sharedAuthTablesRoutes from "./sharedAuthTablesRoutes.js";
import sharedAdminTablesRoutes from "./sharedAdminTablesRoutes.js";
import { requireAdmin, requireAuth } from "../middlewares/authMiddleware.js";

const router = express.Router();

router.get("/health", (req, res) => {
  res.json({ status: "ok", service: "swi" });
});

router.use(authRoutes);

const protectedRouter = express.Router();
protectedRouter.use(requireAuth, swiTablesRoutes);
protectedRouter.use(requireAuth, swiAssignmentRoutes);
protectedRouter.use("/tickets", requireAuth, ticketsRoutes);
protectedRouter.use(requireAuth, sharedAuthTablesRoutes);
protectedRouter.use(requireAdmin, sharedAdminTablesRoutes);

router.use(protectedRouter);

export default router;
