reorder routes for correctness

This commit is contained in:
Alex Holliday committed 2025-07-21 09:55:49 -07:00
1 parent dae0d6cc42
commit 0c04db3299
17 files changed
+123 -127

No files matched your search

+8 -6
View File
@@ -13,23 +13,24 @@ class CheckRoutes {
}
initRoutes() {
this.router.get("/team", this.checkController.getChecksByTeam);
this.router.get("/team/summary", this.checkController.getChecksSummaryByTeamId);
this.router.get("/team", this.checkController.getChecksByTeam);
this.router.put(
"/team/ttl",
isAllowed(["admin", "superadmin"]),
this.checkController.updateChecksTTL
);
this.router.delete(
"/team",
isAllowed(["admin", "superadmin"]),
this.checkController.deleteChecksByTeamId
);
this.router.put(
"/check/:checkId",
verifyTeamAccess(Check, "checkId"),
this.checkController.ackCheck
);
this.router.put(
"/team/ttl",
isAllowed(["admin", "superadmin"]),
this.checkController.updateChecksTTL
);
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
this.router.post(
@@ -42,6 +43,7 @@ class CheckRoutes {
verifyOwnership(Monitor, "monitorId"),
this.checkController.deleteChecks
);
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
}
+2 -3
View File
@@ -7,13 +7,12 @@ class DiagnosticRoutes {
this.initRoutes();
}
initRoutes() {
this.router.post("/db/stats", this.diagnosticController.getDbStats);
this.router.get("/system", this.diagnosticController.getSystemStats);
this.router.get(
"/db/get-monitors-by-team-id/:teamId",
this.diagnosticController.getMonitorsByTeamIdExecutionStats
);
this.router.post("/db/stats", this.diagnosticController.getDbStats);
this.router.get("/system", this.diagnosticController.getSystemStats);
}
getRouter() {
+6 -7
View File
@@ -10,15 +10,14 @@ class InviteRoutes {
}
initRoutes() {
this.router.post(
"/",
isAllowed(["admin", "superadmin"]),
verifyJWT,
this.inviteController.getInviteToken
);
this.router.post("/send", this.inviteController.sendInviteEmail);
this.router.post("/verify", this.inviteController.inviteVerifyController);
this.router.post(
"/",
verifyJWT,
isAllowed(["admin", "superadmin"]),
this.inviteController.getInviteToken
);
}
getRouter() {
+7 -13
View File
@@ -6,35 +6,29 @@ import MaintenanceWindow from "../db/models/MaintenanceWindow.js";
class MaintenanceWindowRoutes {
constructor(maintenanceWindowController) {
this.router = Router();
this.maintenanceWindowController = maintenanceWindowController;
this.mwController = maintenanceWindowController;
this.initRoutes();
}
initRoutes() {
this.router.post("/", this.maintenanceWindowController.createMaintenanceWindows);
this.router.post("/", this.mwController.createMaintenanceWindows);
this.router.get("/team/", this.mwController.getMaintenanceWindowsByTeamId);
this.router.get(
"/monitor/:monitorId",
verifyOwnership(Monitor, "monitorId"),
this.maintenanceWindowController.getMaintenanceWindowsByMonitorId
this.mwController.getMaintenanceWindowsByMonitorId
);
this.router.get(
"/team/",
this.maintenanceWindowController.getMaintenanceWindowsByTeamId
);
this.router.get("/:id", this.maintenanceWindowController.getMaintenanceWindowById);
this.router.get("/:id", this.mwController.getMaintenanceWindowById);
this.router.put(
"/:id",
verifyTeamAccess(MaintenanceWindow, "id"),
this.maintenanceWindowController.editMaintenanceWindow
this.mwController.editMaintenanceWindow
);
this.router.delete(
"/:id",
verifyTeamAccess(MaintenanceWindow, "id"),
this.maintenanceWindowController.deleteMaintenanceWindow
this.mwController.deleteMaintenanceWindow
);
}
+52 -51
View File
@@ -17,22 +17,43 @@ class MonitorRoutes {
}
initRoutes() {
this.router.get("/", this.monitorController.getAllMonitors);
// Team routes
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
this.router.get(
"/team/with-checks",
this.monitorController.getMonitorsWithChecksByTeamId
);
this.router.get(
"/summary/team",
this.monitorController.getMonitorsAndSummaryByTeamId
); // TODO should be /team/summary
// Uptime routes
this.router.get("/uptime", this.monitorController.getAllMonitorsWithUptimeStats);
this.router.get(
"/export",
isAllowed(["admin", "superadmin"]),
this.monitorController.exportMonitorsToCSV
"/uptime/details/:monitorId",
this.monitorController.getUptimeDetailsById
);
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
// Hardware routes
this.router.get(
"/hardware/details/:monitorId",
this.monitorController.getHardwareDetailsById
);
// General monitor routes
this.router.post(
"/pause/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.pauseMonitor
);
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
// Util routes
this.router.get(
"/uptime/details/:monitorId",
this.monitorController.getUptimeDetailsById
"/resolution/url",
isAllowed(["admin", "superadmin"]),
this.monitorController.checkEndpointResolution
);
this.router.get("/certificate/:monitorId", (req, res, next) => {
this.monitorController.getMonitorCertificate(
@@ -42,78 +63,58 @@ class MonitorRoutes {
fetchMonitorCertificate
);
});
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.get(
"/summary/team",
this.monitorController.getMonitorsAndSummaryByTeamId
);
this.router.get(
"/team/with-checks",
this.monitorController.getMonitorsWithChecksByTeamId
);
this.router.get(
"/resolution/url",
isAllowed(["admin", "superadmin"]),
this.monitorController.checkEndpointResolution
);
this.router.delete(
"/:monitorId",
verifyOwnership(Monitor, "monitorId"),
isAllowed(["admin", "superadmin"]),
this.monitorController.deleteMonitor
);
// General monitor CRUD routes
this.router.get("/", this.monitorController.getAllMonitors);
this.router.post(
"/",
isAllowed(["admin", "superadmin"]),
this.monitorController.createMonitor
);
this.router.put(
"/:monitorId",
verifyTeamAccess(Monitor, "monitorId"),
isAllowed(["admin", "superadmin"]),
this.monitorController.editMonitor
);
this.router.delete(
"/",
isAllowed(["superadmin"]),
this.monitorController.deleteAllMonitors
);
this.router.post(
"/pause/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.pauseMonitor
);
// Other static routes
this.router.post(
"/demo",
isAllowed(["admin", "superadmin"]),
this.monitorController.addDemoMonitors
);
this.router.get(
"/export",
isAllowed(["admin", "superadmin"]),
this.monitorController.exportMonitorsToCSV
);
this.router.post("/seed", isAllowed(["superadmin"]), this.monitorController.seedDb);
this.router.post(
"/bulk",
isAllowed(["admin", "superadmin"]),
upload.single("csvFile"),
this.monitorController.createBulkMonitors
);
this.router.post("/seed", isAllowed(["superadmin"]), this.monitorController.seedDb);
this.router.post(
"/test-email",
isAllowed(["admin", "superadmin"]),
this.monitorController.sendTestEmail
);
// Individual monitor CRUD routes
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.put(
"/:monitorId",
verifyTeamAccess(Monitor, "monitorId"),
isAllowed(["admin", "superadmin"]),
this.monitorController.editMonitor
);
this.router.delete(
"/:monitorId",
verifyOwnership(Monitor, "monitorId"),
isAllowed(["admin", "superadmin"]),
this.monitorController.deleteMonitor
);
}
getRouter() {
+3 -4
View File
@@ -13,11 +13,11 @@ class NotificationRoutes {
initializeRoutes() {
this.router.use(verifyJWT);
this.router.post("/test", this.notificationController.testNotification);
this.router.post("/test/all", this.notificationController.testAllNotifications);
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.delete(
@@ -25,7 +25,6 @@ class NotificationRoutes {
verifyOwnership(Notification, "id"),
this.notificationController.deleteNotification
);
this.router.get("/:id", this.notificationController.getNotificationById);
this.router.put(
"/:id",
+13 -17
View File
@@ -7,41 +7,37 @@ class QueueRoutes {
this.initRoutes();
}
initRoutes() {
this.router.get(
"/metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getMetrics
);
this.router.get(
"/jobs",
isAllowed(["admin", "superadmin"]),
this.queueController.getJobs
);
this.router.get(
"/all-metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getAllMetrics
);
this.router.post(
"/jobs",
isAllowed(["admin", "superadmin"]),
this.queueController.addJob
);
this.router.post(
"/flush",
this.router.get(
"/metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.flushQueue
this.queueController.getMetrics
);
this.router.get(
"/health",
isAllowed(["admin", "superadmin"]),
this.queueController.checkQueueHealth
);
this.router.get(
"/all-metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getAllMetrics
);
this.router.post(
"/flush",
isAllowed(["admin", "superadmin"]),
this.queueController.flushQueue
);
}
getRouter() {
+2 -1
View File
@@ -13,7 +13,6 @@ class StatusPageRoutes {
initRoutes() {
this.router.get("/", this.statusPageController.getStatusPage);
this.router.get("/team", verifyJWT, this.statusPageController.getStatusPagesByTeamId);
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.post(
"/",
@@ -27,6 +26,8 @@ class StatusPageRoutes {
verifyJWT,
this.statusPageController.updateStatusPage
);
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.delete("/:url(*)", verifyJWT, this.statusPageController.deleteStatusPage);
}