Merge pull request #3162 from ajhollid/fix/routes

fix/routes
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-01-21 10:37:21 -08:00
commit 147eff3ede
13 files changed
+74 -42

No files matched your search

+12 -13
View File
@@ -1,23 +1,22 @@
import { createVerifyJWT } from "../middleware/verifyJWT.js"; import { createVerifyJWT } from "../middleware/verifyJWT.js";
import { authApiLimiter } from "../middleware/rateLimiter.js"; import { authApiLimiter } from "../middleware/rateLimiter.js";
import AuthRoutes from "../routes/v1/authRoute.js"; import AuthRoutes from "../routes/authRoute.js";
import InviteRoutes from "../routes/v1/inviteRoute.js"; import InviteRoutes from "../routes/inviteRoute.js";
import MonitorRoutes from "../routes/v1/monitorRoute.js"; import MonitorRoutes from "../routes/monitorRoute.js";
import CheckRoutes from "../routes/v1/checkRoute.js"; import CheckRoutes from "../routes/checkRoute.js";
import SettingsRoutes from "../routes/v1/settingsRoute.js"; import SettingsRoutes from "../routes/settingsRoute.js";
import MaintenanceWindowRoutes from "../routes/v1/maintenanceWindowRoute.js"; import MaintenanceWindowRoutes from "../routes/maintenanceWindowRoute.js";
import StatusPageRoutes from "../routes/v1/statusPageRoute.js"; import StatusPageRoutes from "../routes/statusPageRoute.js";
import QueueRoutes from "../routes/v1/queueRoute.js"; import QueueRoutes from "../routes/queueRoute.js";
import LogRoutes from "../routes/v1/logRoutes.js"; import LogRoutes from "../routes/logRoutes.js";
import DiagnosticRoutes from "../routes/v1/diagnosticRoute.js"; import DiagnosticRoutes from "../routes/diagnosticRoute.js";
import NotificationRoutes from "../routes/v1/notificationRoute.js"; import NotificationRoutes from "../routes/notificationRoute.js";
import IncidentRoutes from "../routes/v1/incidentRoute.js"; import IncidentRoutes from "../routes/incidentRoute.js";
export const setupRoutes = (app: any, controllers: Record<string, any>, services: Record<string, any>) => { export const setupRoutes = (app: any, controllers: Record<string, any>, services: Record<string, any>) => {
const verifyJWT = createVerifyJWT(services.settingsService); const verifyJWT = createVerifyJWT(services.settingsService);
// V1
const authRoutes = new AuthRoutes(controllers.authController, verifyJWT); const authRoutes = new AuthRoutes(controllers.authController, verifyJWT);
const monitorRoutes = new MonitorRoutes(controllers.monitorController); const monitorRoutes = new MonitorRoutes(controllers.monitorController);
const settingsRoutes = new SettingsRoutes(controllers.settingsController); const settingsRoutes = new SettingsRoutes(controllers.settingsController);
@@ -1,17 +1,20 @@
import { Router } from "express"; import { Router, RequestHandler } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
import multer from "multer"; import multer from "multer";
const upload = multer(); const upload = multer();
class AuthRoutes { class AuthRoutes {
constructor(authController, verifyJWT) { private router: Router;
private authController: any;
constructor(authController: any, verifyJWT: RequestHandler) {
this.router = Router(); this.router = Router();
this.authController = authController; this.authController = authController;
this.initRoutes(verifyJWT); this.initRoutes(verifyJWT);
} }
initRoutes(verifyJWT) { initRoutes(verifyJWT: RequestHandler) {
this.router.post("/register", upload.single("profileImage"), this.authController.registerUser); this.router.post("/register", upload.single("profileImage"), this.authController.registerUser);
this.router.post("/login", this.authController.loginUser); this.router.post("/login", this.authController.loginUser);
@@ -1,9 +1,12 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class CheckRoutes { class CheckRoutes {
constructor(checkController) { private router: Router;
private checkController: any;
constructor(checkController: any) {
this.router = Router(); this.router = Router();
this.checkController = checkController; this.checkController = checkController;
this.initRoutes(); this.initRoutes();
@@ -1,14 +1,17 @@
import { Router } from "express"; import { RequestHandler, Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class DiagnosticRoutes { class DiagnosticRoutes {
constructor(diagnosticController, verifyJWT) { private router: Router;
private diagnosticController: any;
constructor(diagnosticController: any, verifyJWT: RequestHandler) {
this.router = Router(); this.router = Router();
this.diagnosticController = diagnosticController; this.diagnosticController = diagnosticController;
this.initRoutes(verifyJWT); this.initRoutes(verifyJWT);
} }
initRoutes(verifyJWT) { initRoutes(verifyJWT: RequestHandler) {
this.router.get("/system", verifyJWT, isAllowed(["admin", "superadmin"]), this.diagnosticController.getSystemStats); this.router.get("/system", verifyJWT, isAllowed(["admin", "superadmin"]), this.diagnosticController.getSystemStats);
} }
@@ -1,8 +1,11 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class IncidentRoutes { class IncidentRoutes {
constructor(incidentController) { private router: Router;
private incidentController: any;
constructor(incidentController: any) {
this.router = Router(); this.router = Router();
this.incidentController = incidentController; this.incidentController = incidentController;
this.initRoutes(); this.initRoutes();
@@ -1,14 +1,17 @@
import { Router } from "express"; import { RequestHandler, Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class InviteRoutes { class InviteRoutes {
constructor(inviteController, verifyJWT) { private router: Router;
private inviteController: any;
constructor(inviteController: any, verifyJWT: RequestHandler) {
this.router = Router(); this.router = Router();
this.inviteController = inviteController; this.inviteController = inviteController;
this.initRoutes(verifyJWT); this.initRoutes(verifyJWT);
} }
initRoutes(verifyJWT) { initRoutes(verifyJWT: RequestHandler) {
this.router.post("/send", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.sendInviteEmail); this.router.post("/send", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.sendInviteEmail);
this.router.post("/verify", this.inviteController.verifyInviteToken); this.router.post("/verify", this.inviteController.verifyInviteToken);
this.router.post("/", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.getInviteToken); this.router.post("/", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.getInviteToken);
@@ -1,7 +1,10 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class LogRoutes { class LogRoutes {
constructor(logController) { private router: Router;
private logController: any;
constructor(logController: any) {
this.router = Router(); this.router = Router();
this.logController = logController; this.logController = logController;
this.initRoutes(); this.initRoutes();
@@ -1,7 +1,10 @@
import { Router } from "express"; import { Router } from "express";
class MaintenanceWindowRoutes { class MaintenanceWindowRoutes {
constructor(maintenanceWindowController) { private router: Router;
private mwController: any;
constructor(maintenanceWindowController: any) {
this.router = Router(); this.router = Router();
this.mwController = maintenanceWindowController; this.mwController = maintenanceWindowController;
this.initRoutes(); this.initRoutes();
@@ -1,7 +1,7 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "@/middleware/isAllowed.js";
import multer from "multer"; import multer from "multer";
import { fetchMonitorCertificate } from "../../controllers/controllerUtils.js"; import { fetchMonitorCertificate } from "@/controllers/controllerUtils.js";
const upload = multer({ const upload = multer({
storage: multer.memoryStorage(), // Store file in memory as Buffer storage: multer.memoryStorage(), // Store file in memory as Buffer
}); });
@@ -1,6 +1,9 @@
import { Router } from "express"; import { Router } from "express";
class NotificationRoutes { class NotificationRoutes {
constructor(notificationController) { private router: Router;
private notificationController: any;
constructor(notificationController: any) {
this.router = Router(); this.router = Router();
this.notificationController = notificationController; this.notificationController = notificationController;
this.initializeRoutes(); this.initializeRoutes();
@@ -1,7 +1,10 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class QueueRoutes { class QueueRoutes {
constructor(queueController) { private router: Router;
private queueController: any;
constructor(queueController: any) {
this.router = Router(); this.router = Router();
this.queueController = queueController; this.queueController = queueController;
this.initRoutes(); this.initRoutes();
@@ -1,8 +1,11 @@
import { Router } from "express"; import { Router } from "express";
import { isAllowed } from "../../middleware/isAllowed.js"; import { isAllowed } from "../middleware/isAllowed.js";
class SettingsRoutes { class SettingsRoutes {
constructor(settingsController) { private router: Router;
private settingsController: any;
constructor(settingsController: any) {
this.router = Router(); this.router = Router();
this.settingsController = settingsController; this.settingsController = settingsController;
this.initRoutes(); this.initRoutes();
@@ -1,15 +1,18 @@
import { Router } from "express"; import { RequestHandler, Router } from "express";
import multer from "multer"; import multer from "multer";
const upload = multer(); const upload = multer();
class StatusPageRoutes { class StatusPageRoutes {
constructor(statusPageController, verifyJWT) { private router: Router;
private statusPageController: any;
constructor(statusPageController: any, verifyJWT: RequestHandler) {
this.router = Router(); this.router = Router();
this.statusPageController = statusPageController; this.statusPageController = statusPageController;
this.initRoutes(verifyJWT); this.initRoutes(verifyJWT);
} }
initRoutes(verifyJWT) { initRoutes(verifyJWT: RequestHandler) {
this.router.get("/", this.statusPageController.getStatusPage); this.router.get("/", this.statusPageController.getStatusPage);
this.router.get("/team", verifyJWT, this.statusPageController.getStatusPagesByTeamId); this.router.get("/team", verifyJWT, this.statusPageController.getStatusPagesByTeamId);