/**
 * @deprecated Stray duplicate of ORAC routing; not a supported entry. Use `combined-server.mjs` or `Risk_assessment_backend/src/server.js`.
 * Archived from repo root — do not execute from this folder (imports will not resolve).
 */
import express from "express";
import authRoutes from "./authRoutes.js";
import accountStatusRoutes from "./accountStatusRoutes.js";
import countryRoutes from "./countryRoutes.js";
import departmentsRoutes from "./departmentsRoutes.js";
import jobTitleRoutes from "./jobTitleRoutes.js";
import locationsRoutes from "./locationsRoutes.js";
import lookupRoutes from "./lookupRoutes.js";
import locationDepartmentsRoutes from "./locationDepartmentsRoutes.js";
import oracAnswersRoutes from "./oracAnswersRoutes.js";
import oracArchiveFormRoutes from "./oracArchiveFormRoutes.js";
import oracArchiveSectionRoutes from "./oracArchiveSectionRoutes.js";
import oracAssessmentsRoutes from "./oracAssessmentsRoutes.js";
import oracAssessmentsStatusRoutes from "./oracAssessmentsStatusRoutes.js";
import oracCombinedQuestionRoutes from "./oracCombinedQuestionRoutes.js";
import oracFormDetailsRoutes from "./oracFormDetailsRoutes.js";
import oracFormLogsRoutes from "./oracFormLogsRoutes.js";
import oracFormSectionMapRoutes from "./oracFormSectionMapRoutes.js";
import oracLocationFormsDetailsRoutes from "./oracLocationFormsDetailsRoutes.js";
import oracParticipantsRoutes from "./oracParticipantsRoutes.js";
import rpnRoutes from "./rpnRoutes.js";
import oracQuestionOptionsRoutes from "./oracQuestionOptionsRoutes.js";
import oracQuestionTypeRoutes from "./oracQuestionTypeRoutes.js";
import oracQuestionsRoutes from "./oracQuestionsRoutes.js";
import oracSectionDetailsRoutes from "./oracSectionDetailsRoutes.js";
import oracSectionLogsRoutes from "./oracSectionLogsRoutes.js";
import oracSectionQuestionMapRoutes from "./oracSectionQuestionMapRoutes.js";
import oracSnapsRoutes from "./oracSnapsRoutes.js";
import oracSubmissionsRoutes from "./oracSubmissionsRoutes.js";
import oracVerificationFlowRoutes from "./oracVerificationFlowRoutes.js";
import rolesRoutes from "./rolesRoutes.js";
import ticketsRoutes from "./ticketsRoutes.js";
import ticketsLogsRoutes from "./ticketsLogsRoutes.js";
import ticketsStatusRoutes from "./ticketsStatusRoutes.js";
import ticketsTypeRoutes from "./ticketsTypeRoutes.js";
import userRoleRoutes from "./userRoleRoutes.js";
import usersRoutes from "./usersRoutes.js";
import usersLogsRoutes from "./usersLogsRoutes.js";
import { requireAdmin, requireAuth } from "../middlewares/authMiddleware.js";

const router = express.Router();

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

router.use(authRoutes);

/** All JWT-protected application APIs live under `/api/orac` (health + login stay at `/api/health`, `/api/auth/login`). */
const oracRouter = express.Router();

// Shared routes — user, admin, and executor/verifier JWTs (requireAuth tries all secrets)
oracRouter.use(requireAuth, oracAssessmentsRoutes);
oracRouter.use(requireAuth, oracAssessmentsStatusRoutes);
oracRouter.use(requireAuth, oracParticipantsRoutes);
oracRouter.use(requireAuth, oracSnapsRoutes);

// Shared lookup data — both user and admin need these for forms
oracRouter.use(requireAuth, locationsRoutes);
oracRouter.use(requireAuth, lookupRoutes);
oracRouter.use(requireAuth, departmentsRoutes);
oracRouter.use(requireAuth, locationDepartmentsRoutes);
oracRouter.use(requireAuth, oracSectionQuestionMapRoutes);
oracRouter.use(requireAuth, oracFormSectionMapRoutes);
oracRouter.use(requireAuth, oracSubmissionsRoutes);
oracRouter.use(requireAuth, rpnRoutes);

// Former user-only ORAC / ticket routes — executor & verifier JWTs (requireAuth) may access as well
oracRouter.use(requireAuth, oracAnswersRoutes);
oracRouter.use(requireAuth, oracArchiveFormRoutes);
oracRouter.use(requireAuth, oracArchiveSectionRoutes);
oracRouter.use(requireAuth, oracCombinedQuestionRoutes);
oracRouter.use(requireAuth, oracFormDetailsRoutes);
oracRouter.use(requireAuth, oracFormLogsRoutes);
oracRouter.use(requireAuth, oracLocationFormsDetailsRoutes);
oracRouter.use(requireAuth, oracQuestionOptionsRoutes);
oracRouter.use(requireAuth, oracQuestionTypeRoutes);
oracRouter.use(requireAuth, oracQuestionsRoutes);
oracRouter.use(requireAuth, oracSectionDetailsRoutes);
oracRouter.use(requireAuth, oracSectionLogsRoutes);
oracRouter.use(requireAuth, oracVerificationFlowRoutes);
oracRouter.use(requireAuth, ticketsRoutes);
oracRouter.use(requireAuth, ticketsLogsRoutes);
oracRouter.use(requireAuth, ticketsStatusRoutes);
oracRouter.use(requireAuth, ticketsTypeRoutes);

// Admin-only APIs
oracRouter.use(requireAdmin, accountStatusRoutes);
oracRouter.use(requireAdmin, countryRoutes);
oracRouter.use(requireAdmin, jobTitleRoutes);
oracRouter.use(requireAdmin, rolesRoutes);
oracRouter.use(requireAdmin, userRoleRoutes);
oracRouter.use(requireAdmin, usersRoutes);
oracRouter.use(requireAdmin, usersLogsRoutes);

router.use("/orac", oracRouter);

export default router;
