From 846564a17e630c7750077fd921cc24091026e8e3 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 21 Jul 2025 10:34:04 -0700 Subject: [PATCH] reorder routes --- server/.prettierrc | 2 +- server/routes/authRoute.js | 36 +++------------ server/routes/monitorRoute.js | 83 ++++++---------------------------- server/routes/settingsRoute.js | 12 +---- 4 files changed, 24 insertions(+), 109 deletions(-) diff --git a/server/.prettierrc b/server/.prettierrc index 5c345e37a..681669aa7 100755 --- a/server/.prettierrc +++ b/server/.prettierrc @@ -1,5 +1,5 @@ { - "printWidth": 90, + "printWidth": 150, "useTabs": true, "tabWidth": 2, "singleQuote": false, diff --git a/server/routes/authRoute.js b/server/routes/authRoute.js index aabd8de89..127456c02 100755 --- a/server/routes/authRoute.js +++ b/server/routes/authRoute.js @@ -15,40 +15,18 @@ class AuthRoutes { } initRoutes() { - 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.put( - "/user/:userId", - upload.single("profileImage"), - verifyJWT, - this.authController.editUser - ); - - this.router.get("/users/superadmin", this.authController.checkSuperadminExists); - - this.router.get( - "/users", - verifyJWT, - isAllowed(["admin", "superadmin"]), - this.authController.getAllUsers - ); - - this.router.delete( - "/user/:userId", - verifyJWT, - verifyOwnership(User, "userId"), - this.authController.deleteUser - ); - - // Recovery routes 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.put("/user/:userId", verifyJWT, upload.single("profileImage"), this.authController.editUser); + this.router.delete("/user/:userId", verifyJWT, verifyOwnership(User, "userId"), this.authController.deleteUser); } getRouter() { diff --git a/server/routes/monitorRoute.js b/server/routes/monitorRoute.js index 3e39f4459..2911bf9d7 100755 --- a/server/routes/monitorRoute.js +++ b/server/routes/monitorRoute.js @@ -19,96 +19,41 @@ class MonitorRoutes { initRoutes() { // 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 + 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/details/:monitorId", - this.monitorController.getUptimeDetailsById - ); + this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById); // Hardware routes - this.router.get( - "/hardware/details/:monitorId", - this.monitorController.getHardwareDetailsById - ); + 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.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.pauseMonitor); this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById); // Util routes - this.router.get( - "/resolution/url", - isAllowed(["admin", "superadmin"]), - this.monitorController.checkEndpointResolution - ); + this.router.get("/resolution/url", isAllowed(["admin", "superadmin"]), this.monitorController.checkEndpointResolution); this.router.get("/certificate/:monitorId", (req, res, next) => { - this.monitorController.getMonitorCertificate( - req, - res, - next, - fetchMonitorCertificate - ); + this.monitorController.getMonitorCertificate(req, res, next, fetchMonitorCertificate); }); // General monitor CRUD routes this.router.get("/", this.monitorController.getAllMonitors); - this.router.post( - "/", - isAllowed(["admin", "superadmin"]), - this.monitorController.createMonitor - ); - this.router.delete( - "/", - isAllowed(["superadmin"]), - this.monitorController.deleteAllMonitors - ); + 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", - isAllowed(["admin", "superadmin"]), - this.monitorController.exportMonitorsToCSV - ); + 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( - "/test-email", - isAllowed(["admin", "superadmin"]), - this.monitorController.sendTestEmail - ); + this.router.post("/bulk", isAllowed(["admin", "superadmin"]), upload.single("csvFile"), this.monitorController.createBulkMonitors); + 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.put("/:monitorId", verifyTeamAccess(Monitor, "monitorId"), isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor); this.router.delete( "/:monitorId", verifyOwnership(Monitor, "monitorId"), diff --git a/server/routes/settingsRoute.js b/server/routes/settingsRoute.js index f293fd660..88eb67e65 100755 --- a/server/routes/settingsRoute.js +++ b/server/routes/settingsRoute.js @@ -10,16 +10,8 @@ class SettingsRoutes { initRoutes() { this.router.get("/", this.settingsController.getAppSettings); - this.router.put( - "/", - isAllowed(["admin", "superadmin"]), - this.settingsController.updateAppSettings - ); - this.router.post( - "/test-email", - isAllowed(["admin", "superadmin"]), - this.settingsController.sendTestEmail - ); + this.router.put("/", isAllowed(["admin", "superadmin"]), this.settingsController.updateAppSettings); + this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.settingsController.sendTestEmail); } getRouter() {