Merge pull request #2650 from bluewave-labs/fix/route-reorder

fix: reorder routes for correctness
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-07-21 09:56:50 -07:00
commit 46d7009837
17 files changed
+123 -127

No files matched your search

+10 -7
View File
@@ -39,13 +39,16 @@ const verifyJWT = (req, res, next) => {
const { jwtSecret } = ServiceRegistry.get(SettingsService.SERVICE_NAME).getSettings(); const { jwtSecret } = ServiceRegistry.get(SettingsService.SERVICE_NAME).getSettings();
jwt.verify(parsedToken, jwtSecret, (err, decoded) => { jwt.verify(parsedToken, jwtSecret, (err, decoded) => {
if (err) { if (err) {
if (err) { const errorMessage =
const errorMessage = err.name === "TokenExpiredError"
err.name === "TokenExpiredError" ? stringService.expiredAuthToken
? stringService.expiredAuthToken : stringService.invalidAuthToken;
: stringService.invalidAuthToken; err.details = { msg: errorMessage };
return res.status(401).json({ success: false, msg: errorMessage }); err.status = 401;
} err.service = SERVICE_NAME;
err.method = "verifyJWT";
next(err);
return;
} else { } else {
// Token is valid, carry on // Token is valid, carry on
req.user = decoded; req.user = decoded;
+8 -6
View File
@@ -13,23 +13,24 @@ class CheckRoutes {
} }
initRoutes() { initRoutes() {
this.router.get("/team", this.checkController.getChecksByTeam);
this.router.get("/team/summary", this.checkController.getChecksSummaryByTeamId); 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( this.router.delete(
"/team", "/team",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.checkController.deleteChecksByTeamId this.checkController.deleteChecksByTeamId
); );
this.router.put( this.router.put(
"/check/:checkId", "/check/:checkId",
verifyTeamAccess(Check, "checkId"), verifyTeamAccess(Check, "checkId"),
this.checkController.ackCheck this.checkController.ackCheck
); );
this.router.put(
"/team/ttl",
isAllowed(["admin", "superadmin"]),
this.checkController.updateChecksTTL
);
this.router.get("/:monitorId", this.checkController.getChecksByMonitor); this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
this.router.post( this.router.post(
@@ -42,6 +43,7 @@ class CheckRoutes {
verifyOwnership(Monitor, "monitorId"), verifyOwnership(Monitor, "monitorId"),
this.checkController.deleteChecks this.checkController.deleteChecks
); );
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks); this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
} }
+2 -3
View File
@@ -7,13 +7,12 @@ class DiagnosticRoutes {
this.initRoutes(); this.initRoutes();
} }
initRoutes() { initRoutes() {
this.router.post("/db/stats", this.diagnosticController.getDbStats);
this.router.get("/system", this.diagnosticController.getSystemStats);
this.router.get( this.router.get(
"/db/get-monitors-by-team-id/:teamId", "/db/get-monitors-by-team-id/:teamId",
this.diagnosticController.getMonitorsByTeamIdExecutionStats this.diagnosticController.getMonitorsByTeamIdExecutionStats
); );
this.router.post("/db/stats", this.diagnosticController.getDbStats);
this.router.get("/system", this.diagnosticController.getSystemStats);
} }
getRouter() { getRouter() {
+6 -7
View File
@@ -10,15 +10,14 @@ class InviteRoutes {
} }
initRoutes() { initRoutes() {
this.router.post(
"/",
isAllowed(["admin", "superadmin"]),
verifyJWT,
this.inviteController.getInviteToken
);
this.router.post("/send", this.inviteController.sendInviteEmail); this.router.post("/send", this.inviteController.sendInviteEmail);
this.router.post("/verify", this.inviteController.inviteVerifyController); this.router.post("/verify", this.inviteController.inviteVerifyController);
this.router.post(
"/",
verifyJWT,
isAllowed(["admin", "superadmin"]),
this.inviteController.getInviteToken
);
} }
getRouter() { getRouter() {
+7 -13
View File
@@ -6,35 +6,29 @@ import MaintenanceWindow from "../db/models/MaintenanceWindow.js";
class MaintenanceWindowRoutes { class MaintenanceWindowRoutes {
constructor(maintenanceWindowController) { constructor(maintenanceWindowController) {
this.router = Router(); this.router = Router();
this.maintenanceWindowController = maintenanceWindowController; this.mwController = maintenanceWindowController;
this.initRoutes(); this.initRoutes();
} }
initRoutes() { initRoutes() {
this.router.post("/", this.maintenanceWindowController.createMaintenanceWindows); this.router.post("/", this.mwController.createMaintenanceWindows);
this.router.get("/team/", this.mwController.getMaintenanceWindowsByTeamId);
this.router.get( this.router.get(
"/monitor/:monitorId", "/monitor/:monitorId",
verifyOwnership(Monitor, "monitorId"), verifyOwnership(Monitor, "monitorId"),
this.maintenanceWindowController.getMaintenanceWindowsByMonitorId this.mwController.getMaintenanceWindowsByMonitorId
); );
this.router.get( this.router.get("/:id", this.mwController.getMaintenanceWindowById);
"/team/",
this.maintenanceWindowController.getMaintenanceWindowsByTeamId
);
this.router.get("/:id", this.maintenanceWindowController.getMaintenanceWindowById);
this.router.put( this.router.put(
"/:id", "/:id",
verifyTeamAccess(MaintenanceWindow, "id"), verifyTeamAccess(MaintenanceWindow, "id"),
this.maintenanceWindowController.editMaintenanceWindow this.mwController.editMaintenanceWindow
); );
this.router.delete( this.router.delete(
"/:id", "/:id",
verifyTeamAccess(MaintenanceWindow, "id"), verifyTeamAccess(MaintenanceWindow, "id"),
this.maintenanceWindowController.deleteMaintenanceWindow this.mwController.deleteMaintenanceWindow
); );
} }
+52 -51
View File
@@ -17,22 +17,43 @@ class MonitorRoutes {
} }
initRoutes() { 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("/uptime", this.monitorController.getAllMonitorsWithUptimeStats);
this.router.get( this.router.get(
"/export", "/uptime/details/:monitorId",
isAllowed(["admin", "superadmin"]), this.monitorController.getUptimeDetailsById
this.monitorController.exportMonitorsToCSV
); );
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
// Hardware routes
this.router.get( this.router.get(
"/hardware/details/:monitorId", "/hardware/details/:monitorId",
this.monitorController.getHardwareDetailsById 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( this.router.get(
"/uptime/details/:monitorId", "/resolution/url",
this.monitorController.getUptimeDetailsById isAllowed(["admin", "superadmin"]),
this.monitorController.checkEndpointResolution
); );
this.router.get("/certificate/:monitorId", (req, res, next) => { this.router.get("/certificate/:monitorId", (req, res, next) => {
this.monitorController.getMonitorCertificate( this.monitorController.getMonitorCertificate(
@@ -42,78 +63,58 @@ class MonitorRoutes {
fetchMonitorCertificate 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( this.router.post(
"/", "/",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.monitorController.createMonitor this.monitorController.createMonitor
); );
this.router.put(
"/:monitorId",
verifyTeamAccess(Monitor, "monitorId"),
isAllowed(["admin", "superadmin"]),
this.monitorController.editMonitor
);
this.router.delete( this.router.delete(
"/", "/",
isAllowed(["superadmin"]), isAllowed(["superadmin"]),
this.monitorController.deleteAllMonitors this.monitorController.deleteAllMonitors
); );
this.router.post( // Other static routes
"/pause/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.pauseMonitor
);
this.router.post( this.router.post(
"/demo", "/demo",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.monitorController.addDemoMonitors 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( this.router.post(
"/bulk", "/bulk",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
upload.single("csvFile"), upload.single("csvFile"),
this.monitorController.createBulkMonitors this.monitorController.createBulkMonitors
); );
this.router.post("/seed", isAllowed(["superadmin"]), this.monitorController.seedDb);
this.router.post( this.router.post(
"/test-email", "/test-email",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.monitorController.sendTestEmail 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() { getRouter() {
+3 -4
View File
@@ -13,11 +13,11 @@ class NotificationRoutes {
initializeRoutes() { initializeRoutes() {
this.router.use(verifyJWT); 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("/", 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("/team", this.notificationController.getNotificationsByTeamId);
this.router.delete( this.router.delete(
@@ -25,7 +25,6 @@ class NotificationRoutes {
verifyOwnership(Notification, "id"), verifyOwnership(Notification, "id"),
this.notificationController.deleteNotification this.notificationController.deleteNotification
); );
this.router.get("/:id", this.notificationController.getNotificationById); this.router.get("/:id", this.notificationController.getNotificationById);
this.router.put( this.router.put(
"/:id", "/:id",
+13 -17
View File
@@ -7,41 +7,37 @@ class QueueRoutes {
this.initRoutes(); this.initRoutes();
} }
initRoutes() { initRoutes() {
this.router.get(
"/metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getMetrics
);
this.router.get( this.router.get(
"/jobs", "/jobs",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.queueController.getJobs this.queueController.getJobs
); );
this.router.get(
"/all-metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getAllMetrics
);
this.router.post( this.router.post(
"/jobs", "/jobs",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.queueController.addJob this.queueController.addJob
); );
this.router.post( this.router.get(
"/flush", "/metrics",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.queueController.flushQueue this.queueController.getMetrics
); );
this.router.get( this.router.get(
"/health", "/health",
isAllowed(["admin", "superadmin"]), isAllowed(["admin", "superadmin"]),
this.queueController.checkQueueHealth 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() { getRouter() {
+2 -1
View File
@@ -13,7 +13,6 @@ class StatusPageRoutes {
initRoutes() { initRoutes() {
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);
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.post( this.router.post(
"/", "/",
@@ -27,6 +26,8 @@ class StatusPageRoutes {
verifyJWT, verifyJWT,
this.statusPageController.updateStatusPage this.statusPageController.updateStatusPage
); );
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.delete("/:url(*)", verifyJWT, this.statusPageController.deleteStatusPage); this.router.delete("/:url(*)", verifyJWT, this.statusPageController.deleteStatusPage);
} }
+1 -1
View File
@@ -30,7 +30,7 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p> <p>
We hope you’re finding Checkmate helpful in monitoring your infrastructure. We hope you’re finding Checkmate helpful in monitoring your infrastructure.
Your support means a lot to us, and we <b>truly appreciate</b> having you as Your support means a lot to us, and we <b>truly appreciate</b> having you as
+4 -2
View File
@@ -29,10 +29,12 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p>One of the admins created an account for you on the Checkmate server.</p> <p>One of the admins created an account for you on the Checkmate server.</p>
<p>You can go ahead and create your account using this link.</p> <p>You can go ahead and create your account using this link.</p>
<p><a href="{{link}}">{{link}}</a></p> <p>
<a href="{{link}}">{{ link }}</a>
</p>
<p>Thank you.</p> <p>Thank you.</p>
</mj-text> </mj-text>
</mj-column> </mj-column>
+3 -3
View File
@@ -47,10 +47,10 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p>{{monitor}} at {{url}} has the following infrastructure alerts:</p> <p>{{ monitor }} at {{ url }} has the following infrastructure alerts:</p>
{{#each alerts}} {{#each alerts}}
<p>• {{this}}</p> <p>• {{ this }}</p>
{{/each}} {{/each}}
</mj-text> </mj-text>
</mj-column> </mj-column>
+1 -1
View File
@@ -45,7 +45,7 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p>There were no incidents this week. Good job!</p> <p>There were no incidents this week. Good job!</p>
<p><b>Current monitors:</b></p> <p><b>Current monitors:</b></p>
<p><b>Google:</b> 100% availability</p> <p><b>Google:</b> 100% availability</p>
+2 -2
View File
@@ -31,10 +31,10 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p> <p>
You are receiving this email because a password reset request has been made You are receiving this email because a password reset request has been made
for {{email}}. Please use the link below on the site to reset your password. for {{ email }}. Please use the link below on the site to reset your password.
</p> </p>
<a href="{{url}}">Reset Password</a> <a href="{{url}}">Reset Password</a>
<p>If you didn't request this, please ignore this email.</p> <p>If you didn't request this, please ignore this email.</p>
+4 -4
View File
@@ -36,7 +36,7 @@
font-size="18px" font-size="18px"
color="red" color="red"
> >
{{monitor}} is down {{ monitor }} is down
</mj-text> </mj-text>
<mj-divider <mj-divider
border-width="2px" border-width="2px"
@@ -47,13 +47,13 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p> <p>
We detected an incident on one of your monitors. Your service is currently We detected an incident on one of your monitors. Your service is currently
down. We'll send a message to you once it is up again. down. We'll send a message to you once it is up again.
</p> </p>
<p><b>Monitor name:</b> {{monitor}}</p> <p><b>Monitor name:</b> {{ monitor }}</p>
<p><b>URL:</b> {{url}}</p> <p><b>URL:</b> {{ url }}</p>
</mj-text> </mj-text>
</mj-column> </mj-column>
<mj-column width="100%"> <mj-column width="100%">
+4 -4
View File
@@ -36,7 +36,7 @@
font-size="18px" font-size="18px"
color="green" color="green"
> >
{{monitor}} is up {{ monitor }} is up
</mj-text> </mj-text>
<mj-divider <mj-divider
border-width="2px" border-width="2px"
@@ -47,10 +47,10 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p>Your latest incident is resolved and your monitored service is up again.</p> <p>Your latest incident is resolved and your monitored service is up again.</p>
<p><b>Monitor name:</b> {{monitor}}</p> <p><b>Monitor name:</b> {{ monitor }}</p>
<p><b>URL:</b> {{url}}</p> <p><b>URL:</b> {{ url }}</p>
</mj-text> </mj-text>
</mj-column> </mj-column>
<mj-column width="100%"> <mj-column width="100%">
+1 -1
View File
@@ -30,7 +30,7 @@
<mj-section> <mj-section>
<mj-column width="100%"> <mj-column width="100%">
<mj-text> <mj-text>
<p>Hello {{name}}!</p> <p>Hello {{ name }}!</p>
<p> <p>
Thank you for trying out Checkmate! We developed it with great care to meet Thank you for trying out Checkmate! We developed it with great care to meet
our own needs, and we're excited to share it with you. our own needs, and we're excited to share it with you.