Merge pull request #3793 from bluewave-labs/chore/refactor-routes

chore: convert router classes to exported functions
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-07-20 11:30:41 -07:00
commit bf255a0178
26 files changed
+256 -469

No files matched your search

-48
View File
@@ -1,48 +0,0 @@
import { Router, RequestHandler } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { imageUpload } from "@/api/middleware/upload.js";
import { IAuthController } from "@/api/controllers/authController.js";
class AuthRoutes {
private router: Router;
private authController: IAuthController;
constructor(authController: IAuthController, verifyJWT: RequestHandler) {
this.router = Router();
this.authController = authController;
this.initRoutes(verifyJWT);
}
initRoutes(verifyJWT: RequestHandler) {
this.router.post("/register", imageUpload.single("profileImage"), this.authController.registerUser);
this.router.post("/login", this.authController.loginUser);
this.router.post("/recovery/request", this.authController.requestRecovery);
this.router.post("/recovery/validate", this.authController.validateRecovery);
this.router.post("/recovery/reset/", this.authController.resetPassword);
this.router.get("/users/superadmin", this.authController.checkSuperadminExists);
this.router.get("/users", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getAllUsers);
this.router.post("/users", verifyJWT, isAllowed(["superadmin"]), imageUpload.single("profileImage"), this.authController.createUser);
this.router.get("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.getUserById);
this.router.patch("/users/:userId", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserById);
this.router.patch("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserPasswordById);
this.router.delete("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.deleteUserById);
this.router.patch(
"/user",
verifyJWT,
imageUpload.single("profileImage"),
isAllowed(["admin", "superadmin", "user"]),
this.authController.editUser
);
this.router.delete("/user", verifyJWT, isAllowed(["admin", "superadmin", "user"]), this.authController.deleteUser);
}
getRouter() {
return this.router;
}
}
export default AuthRoutes;
+27
View File
@@ -0,0 +1,27 @@
import { Router, RequestHandler } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { imageUpload } from "@/api/middleware/upload.js";
import { IAuthController } from "@/api/controllers/authController.js";
export const createAuthRoutes = (authController: IAuthController, verifyJWT: RequestHandler): Router => {
const router = Router();
router.post("/register", imageUpload.single("profileImage"), authController.registerUser);
router.post("/login", authController.loginUser);
router.post("/recovery/request", authController.requestRecovery);
router.post("/recovery/validate", authController.validateRecovery);
router.post("/recovery/reset/", authController.resetPassword);
router.get("/users/superadmin", authController.checkSuperadminExists);
router.get("/users", verifyJWT, isAllowed(["admin", "superadmin"]), authController.getAllUsers);
router.post("/users", verifyJWT, isAllowed(["superadmin"]), imageUpload.single("profileImage"), authController.createUser);
router.get("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), authController.getUserById);
router.patch("/users/:userId", verifyJWT, isAllowed(["superadmin"]), authController.editUserById);
router.patch("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), authController.editUserPasswordById);
router.delete("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), authController.deleteUserById);
router.patch("/user", verifyJWT, imageUpload.single("profileImage"), isAllowed(["admin", "superadmin", "user"]), authController.editUser);
router.delete("/user", verifyJWT, isAllowed(["admin", "superadmin", "user"]), authController.deleteUser);
return router;
};
-29
View File
@@ -1,29 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { ICheckController } from "@/api/controllers/checkController.js";
class CheckRoutes {
private router: Router;
private checkController: ICheckController;
constructor(checkController: ICheckController) {
this.router = Router();
this.checkController = checkController;
this.initRoutes();
}
initRoutes() {
this.router.get("/team/summary", this.checkController.getChecksSummaryByTeamId);
this.router.get("/team", this.checkController.getChecksByTeam);
this.router.delete("/team", isAllowed(["admin", "superadmin"]), this.checkController.deleteChecksByTeamId);
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
this.router.delete("/:monitorId", this.checkController.deleteChecks);
}
getRouter() {
return this.router;
}
}
export default CheckRoutes;
+14
View File
@@ -0,0 +1,14 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { ICheckController } from "@/api/controllers/checkController.js";
export const createCheckRoutes = (checkController: ICheckController): Router => {
const router = Router();
router.get("/team/summary", checkController.getChecksSummaryByTeamId);
router.get("/team", checkController.getChecksByTeam);
router.delete("/team", isAllowed(["admin", "superadmin"]), checkController.deleteChecksByTeamId);
router.get("/:monitorId", checkController.getChecksByMonitor);
router.delete("/:monitorId", checkController.deleteChecks);
return router;
};
-24
View File
@@ -1,24 +0,0 @@
import { RequestHandler, Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IDiagnosticController } from "@/api/controllers/diagnosticController.js";
class DiagnosticRoutes {
private router: Router;
private diagnosticController: IDiagnosticController;
constructor(diagnosticController: IDiagnosticController, verifyJWT: RequestHandler) {
this.router = Router();
this.diagnosticController = diagnosticController;
this.initRoutes(verifyJWT);
}
initRoutes(verifyJWT: RequestHandler) {
this.router.get("/system", verifyJWT, isAllowed(["admin", "superadmin"]), this.diagnosticController.getSystemStats);
}
getRouter() {
return this.router;
}
}
export default DiagnosticRoutes;
@@ -0,0 +1,9 @@
import { RequestHandler, Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IDiagnosticController } from "@/api/controllers/diagnosticController.js";
export const createDiagnosticRoutes = (diagnosticController: IDiagnosticController, verifyJWT: RequestHandler): Router => {
const router = Router();
router.get("/system", verifyJWT, isAllowed(["admin", "superadmin"]), diagnosticController.getSystemStats);
return router;
};
+5 -19
View File
@@ -1,23 +1,9 @@
import { IGeoCheckController } from "@/api/controllers/geoCheckController.js";
import { Router } from "express";
class GeoCheckRoutes {
private router: Router;
private geoCheckController: IGeoCheckController;
export const createGeoCheckRoutes = (geoCheckController: IGeoCheckController): Router => {
const router = Router();
router.get("/:monitorId", geoCheckController.getGeoChecksByMonitor);
constructor(geoCheckController: IGeoCheckController) {
this.router = Router();
this.geoCheckController = geoCheckController;
this.initRoutes();
}
initRoutes() {
this.router.get("/:monitorId", this.geoCheckController.getGeoChecksByMonitor);
}
getRouter() {
return this.router;
}
}
export default GeoCheckRoutes;
return router;
};
-30
View File
@@ -1,30 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IIncidentController } from "@/api/controllers/incidentController.js";
class IncidentRoutes {
private router: Router;
private incidentController: IIncidentController;
constructor(incidentController: IIncidentController) {
this.router = Router();
this.incidentController = incidentController;
this.initRoutes();
}
initRoutes() {
// Team routes
this.router.get("/team", this.incidentController.getIncidentsByTeam);
this.router.get("/team/summary", this.incidentController.getIncidentSummary);
// Individual incident routes
this.router.get("/:incidentId", this.incidentController.getIncidentById);
this.router.put("/:incidentId/resolve", isAllowed(["admin", "superadmin"]), this.incidentController.resolveIncidentManually);
}
getRouter() {
return this.router;
}
}
export default IncidentRoutes;
+12
View File
@@ -0,0 +1,12 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IIncidentController } from "@/api/controllers/incidentController.js";
export const createIncidentRoutes = (incidentController: IIncidentController): Router => {
const router = Router();
router.get("/team", incidentController.getIncidentsByTeam);
router.get("/team/summary", incidentController.getIncidentSummary);
router.get("/:incidentId", incidentController.getIncidentById);
router.put("/:incidentId/resolve", isAllowed(["admin", "superadmin"]), incidentController.resolveIncidentManually);
return router;
};
-26
View File
@@ -1,26 +0,0 @@
import { RequestHandler, Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IInviteController } from "@/api/controllers/inviteController.js";
class InviteRoutes {
private router: Router;
private inviteController: IInviteController;
constructor(inviteController: IInviteController, verifyJWT: RequestHandler) {
this.router = Router();
this.inviteController = inviteController;
this.initRoutes(verifyJWT);
}
initRoutes(verifyJWT: RequestHandler) {
this.router.post("/send", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.sendInviteEmail);
this.router.post("/verify", this.inviteController.verifyInviteToken);
this.router.post("/", verifyJWT, isAllowed(["admin", "superadmin"]), this.inviteController.getInviteToken);
}
getRouter() {
return this.router;
}
}
export default InviteRoutes;
+11
View File
@@ -0,0 +1,11 @@
import { RequestHandler, Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { IInviteController } from "@/api/controllers/inviteController.js";
export const createInviteRoutes = (inviteController: IInviteController, verifyJWT: RequestHandler): Router => {
const router = Router();
router.post("/send", verifyJWT, isAllowed(["admin", "superadmin"]), inviteController.sendInviteEmail);
router.post("/verify", inviteController.verifyInviteToken);
router.post("/", verifyJWT, isAllowed(["admin", "superadmin"]), inviteController.getInviteToken);
return router;
};
+6 -18
View File
@@ -1,22 +1,10 @@
import { Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { ILogController } from "@/api/controllers/logController.js";
class LogRoutes {
private router: Router;
private logController: ILogController;
constructor(logController: ILogController) {
this.router = Router();
this.logController = logController;
this.initRoutes();
}
initRoutes() {
this.router.get("/", isAllowed(["admin", "superadmin"]), this.logController.getLogs);
}
getRouter() {
return this.router;
}
}
export default LogRoutes;
export const createLogRoutes = (logController: ILogController): Router => {
const router = Router();
router.get("/", isAllowed(["admin", "superadmin"]), logController.getLogs);
return router;
};
@@ -1,29 +0,0 @@
import { IMaintenanceWindowController } from "@/api/controllers/maintenanceWindowController.js";
import { Router } from "express";
class MaintenanceWindowRoutes {
private router: Router;
private mwController: IMaintenanceWindowController;
constructor(maintenanceWindowController: IMaintenanceWindowController) {
this.router = Router();
this.mwController = maintenanceWindowController;
this.initRoutes();
}
initRoutes() {
this.router.post("/", this.mwController.createMaintenanceWindows);
this.router.get("/team/", this.mwController.getMaintenanceWindowsByTeamId);
this.router.get("/monitor/:monitorId", this.mwController.getMaintenanceWindowsByMonitorId);
this.router.get("/:id", this.mwController.getMaintenanceWindowById);
this.router.patch("/:id", this.mwController.editMaintenanceWindow);
this.router.delete("/:id", this.mwController.deleteMaintenanceWindow);
}
getRouter() {
return this.router;
}
}
export default MaintenanceWindowRoutes;
@@ -0,0 +1,15 @@
import { IMaintenanceWindowController } from "@/api/controllers/maintenanceWindowController.js";
import { Router } from "express";
export const createMaintenanceWindowRoutes = (maintenanceWindowController: IMaintenanceWindowController): Router => {
const router = Router();
router.post("/", maintenanceWindowController.createMaintenanceWindows);
router.get("/team/", maintenanceWindowController.getMaintenanceWindowsByTeamId);
router.get("/monitor/:monitorId", maintenanceWindowController.getMaintenanceWindowsByMonitorId);
router.get("/:id", maintenanceWindowController.getMaintenanceWindowById);
router.patch("/:id", maintenanceWindowController.editMaintenanceWindow);
router.delete("/:id", maintenanceWindowController.deleteMaintenanceWindow);
return router;
};
-63
View File
@@ -1,63 +0,0 @@
import { Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { IMonitorController } from "@/api/controllers/monitorController.js";
class MonitorRoutes {
private router: Router;
private monitorController: IMonitorController;
constructor(monitorController: IMonitorController) {
this.router = Router();
this.monitorController = monitorController;
this.initRoutes();
}
initRoutes() {
// Team routes
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
this.router.get("/team/with-checks", this.monitorController.getMonitorsWithChecksByTeamId);
// Uptime routes
this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById);
// Hardware routes
this.router.get("/hardware/details/:monitorId", this.monitorController.getHardwareDetailsById);
// PageSpeed routes
this.router.get("/pagespeed/details/:monitorId", this.monitorController.getPageSpeedDetailsById);
// Geo checks routes
this.router.get("/:monitorId/geo-checks", this.monitorController.getGeoChecksByMonitorId);
// General monitor routes
this.router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.pauseMonitor);
this.router.post("/bulk/pause", isAllowed(["admin", "superadmin"]), this.monitorController.bulkPauseMonitors);
// Util routes
this.router.get("/certificate/:monitorId", (req, res, next) => {
this.monitorController.getMonitorCertificate(req, res, next);
});
// General monitor CRUD routes
this.router.patch("/notifications", isAllowed(["admin", "superadmin"]), this.monitorController.updateNotifications);
this.router.post("/", isAllowed(["admin", "superadmin"]), this.monitorController.createMonitor);
this.router.delete("/", isAllowed(["superadmin"]), this.monitorController.deleteAllMonitors);
// Other static routes
this.router.post("/demo", isAllowed(["admin", "superadmin"]), this.monitorController.addDemoMonitors);
this.router.get("/export/json", isAllowed(["admin", "superadmin"]), this.monitorController.exportMonitorsToJSON);
this.router.post("/import/json", isAllowed(["admin", "superadmin"]), this.monitorController.importMonitorsFromJSON);
this.router.get("/games", this.monitorController.getAllGames);
// Individual monitor CRUD routes
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.patch("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor);
this.router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.deleteMonitor);
}
getRouter() {
return this.router;
}
}
export default MonitorRoutes;
+50
View File
@@ -0,0 +1,50 @@
import { Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { IMonitorController } from "@/api/controllers/monitorController.js";
export const createMonitorRoutes = (monitorController: IMonitorController): Router => {
const router = Router();
// Team routes
router.get("/team", monitorController.getMonitorsByTeamId);
router.get("/team/with-checks", monitorController.getMonitorsWithChecksByTeamId);
// Uptime routes
router.get("/uptime/details/:monitorId", monitorController.getUptimeDetailsById);
// Hardware routes
router.get("/hardware/details/:monitorId", monitorController.getHardwareDetailsById);
// PageSpeed routes
router.get("/pagespeed/details/:monitorId", monitorController.getPageSpeedDetailsById);
// Geo checks routes
router.get("/:monitorId/geo-checks", monitorController.getGeoChecksByMonitorId);
// General monitor routes
router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), monitorController.pauseMonitor);
router.post("/bulk/pause", isAllowed(["admin", "superadmin"]), monitorController.bulkPauseMonitors);
// Util routes
router.get("/certificate/:monitorId", (req, res, next) => {
monitorController.getMonitorCertificate(req, res, next);
});
// General monitor CRUD routes
router.patch("/notifications", isAllowed(["admin", "superadmin"]), monitorController.updateNotifications);
router.post("/", isAllowed(["admin", "superadmin"]), monitorController.createMonitor);
router.delete("/", isAllowed(["superadmin"]), monitorController.deleteAllMonitors);
// Other static routes
router.post("/demo", isAllowed(["admin", "superadmin"]), monitorController.addDemoMonitors);
router.get("/export/json", isAllowed(["admin", "superadmin"]), monitorController.exportMonitorsToJSON);
router.post("/import/json", isAllowed(["admin", "superadmin"]), monitorController.importMonitorsFromJSON);
router.get("/games", monitorController.getAllGames);
// Individual monitor CRUD routes
router.get("/:monitorId", monitorController.getMonitorById);
router.patch("/:monitorId", isAllowed(["admin", "superadmin"]), monitorController.editMonitor);
router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), monitorController.deleteMonitor);
return router;
};
@@ -1,31 +0,0 @@
import { INotificationController } from "@/api/controllers/notificationController.js";
import { Router } from "express";
class NotificationRoutes {
private router: Router;
private notificationController: INotificationController;
constructor(notificationController: INotificationController) {
this.router = Router();
this.notificationController = notificationController;
this.initializeRoutes();
}
initializeRoutes() {
this.router.post("/", this.notificationController.createNotification);
this.router.post("/test/all", this.notificationController.testAllNotifications);
this.router.post("/test", this.notificationController.testNotification);
this.router.get("/team", this.notificationController.getNotificationsByTeamId);
this.router.get("/:id", this.notificationController.getNotificationById);
this.router.delete("/:id", this.notificationController.deleteNotification);
this.router.patch("/:id", this.notificationController.editNotification);
}
getRouter() {
return this.router;
}
}
export default NotificationRoutes;
@@ -0,0 +1,14 @@
import { INotificationController } from "@/api/controllers/notificationController.js";
import { Router } from "express";
export const createNotificationRoutes = (notificationController: INotificationController): Router => {
const router = Router();
router.post("/", notificationController.createNotification);
router.post("/test/all", notificationController.testAllNotifications);
router.post("/test", notificationController.testNotification);
router.get("/team", notificationController.getNotificationsByTeamId);
router.get("/:id", notificationController.getNotificationById);
router.delete("/:id", notificationController.deleteNotification);
router.patch("/:id", notificationController.editNotification);
return router;
};
-26
View File
@@ -1,26 +0,0 @@
import { Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { IJobQueueController } from "@/api/controllers/queueController.js";
class QueueRoutes {
private router: Router;
private queueController: IJobQueueController;
constructor(queueController: IJobQueueController) {
this.router = Router();
this.queueController = queueController;
this.initRoutes();
}
initRoutes() {
this.router.get("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.getJobs);
this.router.get("/metrics", isAllowed(["admin", "superadmin"]), this.queueController.getMetrics);
this.router.get("/all-metrics", isAllowed(["admin", "superadmin"]), this.queueController.getAllMetrics);
this.router.post("/flush", isAllowed(["admin", "superadmin"]), this.queueController.flushQueue);
}
getRouter() {
return this.router;
}
}
export default QueueRoutes;
+12
View File
@@ -0,0 +1,12 @@
import { Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { IJobQueueController } from "@/api/controllers/queueController.js";
export const createQueueRoutes = (queueController: IJobQueueController): Router => {
const router = Router();
router.get("/jobs", isAllowed(["admin", "superadmin"]), queueController.getJobs);
router.get("/metrics", isAllowed(["admin", "superadmin"]), queueController.getMetrics);
router.get("/all-metrics", isAllowed(["admin", "superadmin"]), queueController.getAllMetrics);
router.post("/flush", isAllowed(["admin", "superadmin"]), queueController.flushQueue);
return router;
};
-26
View File
@@ -1,26 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { ISettingsController } from "@/api/controllers/settingsController.js";
class SettingsRoutes {
private router: Router;
private settingsController: ISettingsController;
constructor(settingsController: ISettingsController) {
this.router = Router();
this.settingsController = settingsController;
this.initRoutes();
}
initRoutes() {
this.router.get("/", this.settingsController.getAppSettings);
this.router.patch("/", isAllowed(["admin", "superadmin"]), this.settingsController.updateAppSettings);
this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.settingsController.sendTestEmail);
}
getRouter() {
return this.router;
}
}
export default SettingsRoutes;
+11
View File
@@ -0,0 +1,11 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { ISettingsController } from "@/api/controllers/settingsController.js";
export const createSettingsRoutes = (settingsController: ISettingsController): Router => {
const router = Router();
router.get("/", settingsController.getAppSettings);
router.patch("/", isAllowed(["admin", "superadmin"]), settingsController.updateAppSettings);
router.post("/test-email", isAllowed(["admin", "superadmin"]), settingsController.sendTestEmail);
return router;
};
-32
View File
@@ -1,32 +0,0 @@
import { IStatusPageController } from "@/api/controllers/statusPageController.js";
import { RequestHandler, Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { imageUpload } from "@/api/middleware/upload.js";
class StatusPageRoutes {
private router: Router;
private statusPageController: IStatusPageController;
constructor(statusPageController: IStatusPageController, verifyJWT: RequestHandler, verifyStatusPageAccess: RequestHandler) {
this.router = Router();
this.statusPageController = statusPageController;
this.initRoutes(verifyJWT, verifyStatusPageAccess);
}
initRoutes(verifyJWT: RequestHandler, verifyStatusPageAccess: RequestHandler) {
this.router.get("/team", verifyJWT, this.statusPageController.getStatusPagesByTeamId);
this.router.post("/", imageUpload.single("logo"), verifyJWT, isAllowed(["admin", "superadmin"]), this.statusPageController.createStatusPage);
this.router.put("/:id", imageUpload.single("logo"), verifyJWT, isAllowed(["admin", "superadmin"]), this.statusPageController.updateStatusPage);
this.router.get("/resolve", this.statusPageController.resolveStatusPageByDomain);
this.router.get("/:url", verifyStatusPageAccess, this.statusPageController.getStatusPageByUrl);
this.router.delete("/:id", verifyJWT, isAllowed(["admin", "superadmin"]), this.statusPageController.deleteStatusPage);
}
getRouter() {
return this.router;
}
}
export default StatusPageRoutes;
+19
View File
@@ -0,0 +1,19 @@
import { IStatusPageController } from "@/api/controllers/statusPageController.js";
import { RequestHandler, Router } from "express";
import { isAllowed } from "@/api/middleware/isAllowed.js";
import { imageUpload } from "@/api/middleware/upload.js";
export const createStatusPageRoutes = (
statusPageController: IStatusPageController,
verifyJWT: RequestHandler,
verifyStatusPageAccess: RequestHandler
): Router => {
const router = Router();
router.get("/team", verifyJWT, statusPageController.getStatusPagesByTeamId);
router.post("/", imageUpload.single("logo"), verifyJWT, isAllowed(["admin", "superadmin"]), statusPageController.createStatusPage);
router.put("/:id", imageUpload.single("logo"), verifyJWT, isAllowed(["admin", "superadmin"]), statusPageController.updateStatusPage);
router.get("/resolve", statusPageController.resolveStatusPageByDomain);
router.get("/:url", verifyStatusPageAccess, statusPageController.getStatusPageByUrl);
router.delete("/:id", verifyJWT, isAllowed(["admin", "superadmin"]), statusPageController.deleteStatusPage);
return router;
};
+9 -25
View File
@@ -1,28 +1,12 @@
import { ITagsController } from "@/api/controllers/tagController.js";
import { Router } from "express";
class TagRoutes {
private router: Router;
private tagController: ITagsController;
constructor(tagController: ITagsController) {
this.router = Router();
this.tagController = tagController;
this.initializeRoutes();
}
initializeRoutes() {
this.router.post("/", this.tagController.createTag);
this.router.get("/team", this.tagController.getTagsByTeamId);
this.router.get("/:id", this.tagController.getTagById);
this.router.delete("/:id", this.tagController.deleteTag);
this.router.patch("/:id", this.tagController.editTag);
}
getRouter() {
return this.router;
}
}
export default TagRoutes;
export const createTagRoutes = (tagController: ITagsController): Router => {
const router = Router();
router.post("/", tagController.createTag);
router.get("/team", tagController.getTagsByTeamId);
router.get("/:id", tagController.getTagById);
router.delete("/:id", tagController.deleteTag);
router.patch("/:id", tagController.editTag);
return router;
};
+42 -43
View File
@@ -5,52 +5,51 @@ import { authApiLimiter } from "../api/middleware/rateLimiter.js";
import type { InitializedControllers } from "./controllers.js";
import type { ApiServices } from "@/config/services.api.js";
import AuthRoutes from "../api/routes/authRoute.js";
import InviteRoutes from "../api/routes/inviteRoute.js";
import MonitorRoutes from "../api/routes/monitorRoute.js";
import CheckRoutes from "../api/routes/checkRoute.js";
import GeoCheckRoutes from "../api/routes/geoCheckRoutes.js";
import SettingsRoutes from "../api/routes/settingsRoute.js";
import MaintenanceWindowRoutes from "../api/routes/maintenanceWindowRoute.js";
import StatusPageRoutes from "../api/routes/statusPageRoute.js";
import QueueRoutes from "../api/routes/queueRoute.js";
import LogRoutes from "../api/routes/logRoutes.js";
import DiagnosticRoutes from "../api/routes/diagnosticRoute.js";
import NotificationRoutes from "../api/routes/notificationRoute.js";
import TagRoutes from "../api/routes/tagRoutes.js";
import IncidentRoutes from "../api/routes/incidentRoute.js";
import { createAuthRoutes } from "@/api/routes/authRoutes.js";
import { createInviteRoutes } from "@/api/routes/inviteRoutes.js";
import { createMonitorRoutes } from "@/api/routes/monitorRoutes.js";
import { createCheckRoutes } from "@/api/routes/checkRoutes.js";
import { createGeoCheckRoutes } from "@/api/routes/geoCheckRoutes.js";
import { createSettingsRoutes } from "@/api/routes/settingsRoutes.js";
import { createMaintenanceWindowRoutes } from "@/api/routes/maintenanceWindowRoutes.js";
import { createQueueRoutes } from "@/api/routes/queueRoutes.js";
import { createLogRoutes } from "@/api/routes/logRoutes.js";
import { createStatusPageRoutes } from "@/api/routes/statusPageRoutes.js";
import { createDiagnosticRoutes } from "@/api/routes/diagnosticRoutes.js";
import { createNotificationRoutes } from "@/api/routes/notificationRoutes.js";
import { createTagRoutes } from "@/api/routes/tagRoutes.js";
import { createIncidentRoutes } from "@/api/routes/incidentRoutes.js";
export const setupRoutes = (app: Application, controllers: InitializedControllers, apiServices: ApiServices) => {
const verifyJWT = createVerifyJWT(apiServices.settingsService);
const authRoutes = new AuthRoutes(controllers.authController, verifyJWT);
const monitorRoutes = new MonitorRoutes(controllers.monitorController);
const settingsRoutes = new SettingsRoutes(controllers.settingsController);
const checkRoutes = new CheckRoutes(controllers.checkController);
const geoCheckRoutes = new GeoCheckRoutes(controllers.geoCheckController);
const inviteRoutes = new InviteRoutes(controllers.inviteController, verifyJWT);
const maintenanceWindowRoutes = new MaintenanceWindowRoutes(controllers.maintenanceWindowController);
const queueRoutes = new QueueRoutes(controllers.queueController);
const logRoutes = new LogRoutes(controllers.logController);
const authRoutes = createAuthRoutes(controllers.authController, verifyJWT);
const monitorRoutes = createMonitorRoutes(controllers.monitorController);
const settingsRoutes = createSettingsRoutes(controllers.settingsController);
const checkRoutes = createCheckRoutes(controllers.checkController);
const geoCheckRoutes = createGeoCheckRoutes(controllers.geoCheckController);
const inviteRoutes = createInviteRoutes(controllers.inviteController, verifyJWT);
const maintenanceWindowRoutes = createMaintenanceWindowRoutes(controllers.maintenanceWindowController);
const queueRoutes = createQueueRoutes(controllers.queueController);
const logRoutes = createLogRoutes(controllers.logController);
const verifyStatusPageAccess = createVerifyStatusPageAccess(apiServices.statusPagesRepository, verifyJWT);
const statusPageRoutes = new StatusPageRoutes(controllers.statusPageController, verifyJWT, verifyStatusPageAccess);
const notificationRoutes = new NotificationRoutes(controllers.notificationController);
const tagRoutes = new TagRoutes(controllers.tagController);
const diagnosticRoutes = new DiagnosticRoutes(controllers.diagnosticController, verifyJWT);
const incidentRoutes = new IncidentRoutes(controllers.incidentController);
const statusPageRoutes = createStatusPageRoutes(controllers.statusPageController, verifyJWT, verifyStatusPageAccess);
const notificationRoutes = createNotificationRoutes(controllers.notificationController);
const tagRoutes = createTagRoutes(controllers.tagController);
const diagnosticRoutes = createDiagnosticRoutes(controllers.diagnosticController, verifyJWT);
const incidentRoutes = createIncidentRoutes(controllers.incidentController);
app.use("/api/v1/auth", authApiLimiter, authRoutes.getRouter());
app.use("/api/v1/monitors", verifyJWT, monitorRoutes.getRouter());
app.use("/api/v1/settings", verifyJWT, settingsRoutes.getRouter());
app.use("/api/v1/checks", verifyJWT, checkRoutes.getRouter());
app.use("/api/v1/geo-checks", verifyJWT, geoCheckRoutes.getRouter());
app.use("/api/v1/invite", inviteRoutes.getRouter());
app.use("/api/v1/maintenance-window", verifyJWT, maintenanceWindowRoutes.getRouter());
app.use("/api/v1/queue", verifyJWT, queueRoutes.getRouter());
app.use("/api/v1/logs", verifyJWT, logRoutes.getRouter());
app.use("/api/v1/status-page", statusPageRoutes.getRouter());
app.use("/api/v1/notifications", verifyJWT, notificationRoutes.getRouter());
app.use("/api/v1/tags", verifyJWT, tagRoutes.getRouter());
app.use("/api/v1/diagnostic", verifyJWT, diagnosticRoutes.getRouter());
app.use("/api/v1/incidents", verifyJWT, incidentRoutes.getRouter());
app.use("/api/v1/auth", authApiLimiter, authRoutes);
app.use("/api/v1/monitors", verifyJWT, monitorRoutes);
app.use("/api/v1/settings", verifyJWT, settingsRoutes);
app.use("/api/v1/checks", verifyJWT, checkRoutes);
app.use("/api/v1/geo-checks", verifyJWT, geoCheckRoutes);
app.use("/api/v1/invite", inviteRoutes);
app.use("/api/v1/maintenance-window", verifyJWT, maintenanceWindowRoutes);
app.use("/api/v1/queue", verifyJWT, queueRoutes);
app.use("/api/v1/logs", verifyJWT, logRoutes);
app.use("/api/v1/status-page", statusPageRoutes);
app.use("/api/v1/notifications", verifyJWT, notificationRoutes);
app.use("/api/v1/tags", verifyJWT, tagRoutes);
app.use("/api/v1/diagnostic", verifyJWT, diagnosticRoutes);
app.use("/api/v1/incidents", verifyJWT, incidentRoutes);
};