reorder routes
This commit is contained in:
1 parent
46d7009837
commit
846564a17e
4 files changed
+24
-109
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 90,
|
"printWidth": 150,
|
||||||
"useTabs": true,
|
"useTabs": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"singleQuote": false,
|
"singleQuote": false,
|
||||||
|
|||||||
@@ -15,40 +15,18 @@ class AuthRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initRoutes() {
|
initRoutes() {
|
||||||
this.router.post(
|
this.router.post("/register", upload.single("profileImage"), this.authController.registerUser);
|
||||||
"/register",
|
|
||||||
upload.single("profileImage"),
|
|
||||||
this.authController.registerUser
|
|
||||||
);
|
|
||||||
this.router.post("/login", this.authController.loginUser);
|
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/request", this.authController.requestRecovery);
|
||||||
this.router.post("/recovery/validate", this.authController.validateRecovery);
|
this.router.post("/recovery/validate", this.authController.validateRecovery);
|
||||||
this.router.post("/recovery/reset/", this.authController.resetPassword);
|
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() {
|
getRouter() {
|
||||||
|
|||||||
@@ -19,96 +19,41 @@ class MonitorRoutes {
|
|||||||
initRoutes() {
|
initRoutes() {
|
||||||
// Team routes
|
// Team routes
|
||||||
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
|
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
|
||||||
this.router.get(
|
this.router.get("/team/with-checks", this.monitorController.getMonitorsWithChecksByTeamId);
|
||||||
"/team/with-checks",
|
this.router.get("/summary/team", this.monitorController.getMonitorsAndSummaryByTeamId); // TODO should be /team/summary
|
||||||
this.monitorController.getMonitorsWithChecksByTeamId
|
|
||||||
);
|
|
||||||
this.router.get(
|
|
||||||
"/summary/team",
|
|
||||||
this.monitorController.getMonitorsAndSummaryByTeamId
|
|
||||||
); // TODO should be /team/summary
|
|
||||||
|
|
||||||
// Uptime routes
|
// Uptime routes
|
||||||
this.router.get("/uptime", this.monitorController.getAllMonitorsWithUptimeStats);
|
this.router.get("/uptime", this.monitorController.getAllMonitorsWithUptimeStats);
|
||||||
this.router.get(
|
this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById);
|
||||||
"/uptime/details/:monitorId",
|
|
||||||
this.monitorController.getUptimeDetailsById
|
|
||||||
);
|
|
||||||
|
|
||||||
// Hardware routes
|
// Hardware routes
|
||||||
this.router.get(
|
this.router.get("/hardware/details/:monitorId", this.monitorController.getHardwareDetailsById);
|
||||||
"/hardware/details/:monitorId",
|
|
||||||
this.monitorController.getHardwareDetailsById
|
|
||||||
);
|
|
||||||
|
|
||||||
// General monitor routes
|
// General monitor routes
|
||||||
this.router.post(
|
this.router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.pauseMonitor);
|
||||||
"/pause/:monitorId",
|
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.monitorController.pauseMonitor
|
|
||||||
);
|
|
||||||
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
|
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
|
||||||
|
|
||||||
// Util routes
|
// Util routes
|
||||||
this.router.get(
|
this.router.get("/resolution/url", isAllowed(["admin", "superadmin"]), this.monitorController.checkEndpointResolution);
|
||||||
"/resolution/url",
|
|
||||||
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(req, res, next, fetchMonitorCertificate);
|
||||||
req,
|
|
||||||
res,
|
|
||||||
next,
|
|
||||||
fetchMonitorCertificate
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// General monitor CRUD routes
|
// General monitor CRUD routes
|
||||||
this.router.get("/", this.monitorController.getAllMonitors);
|
this.router.get("/", this.monitorController.getAllMonitors);
|
||||||
this.router.post(
|
this.router.post("/", isAllowed(["admin", "superadmin"]), this.monitorController.createMonitor);
|
||||||
"/",
|
this.router.delete("/", isAllowed(["superadmin"]), this.monitorController.deleteAllMonitors);
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.monitorController.createMonitor
|
|
||||||
);
|
|
||||||
this.router.delete(
|
|
||||||
"/",
|
|
||||||
isAllowed(["superadmin"]),
|
|
||||||
this.monitorController.deleteAllMonitors
|
|
||||||
);
|
|
||||||
|
|
||||||
// Other static routes
|
// Other static routes
|
||||||
this.router.post(
|
this.router.post("/demo", isAllowed(["admin", "superadmin"]), this.monitorController.addDemoMonitors);
|
||||||
"/demo",
|
this.router.get("/export", isAllowed(["admin", "superadmin"]), this.monitorController.exportMonitorsToCSV);
|
||||||
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("/seed", isAllowed(["superadmin"]), this.monitorController.seedDb);
|
||||||
this.router.post(
|
this.router.post("/bulk", isAllowed(["admin", "superadmin"]), upload.single("csvFile"), this.monitorController.createBulkMonitors);
|
||||||
"/bulk",
|
this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.monitorController.sendTestEmail);
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
upload.single("csvFile"),
|
|
||||||
this.monitorController.createBulkMonitors
|
|
||||||
);
|
|
||||||
this.router.post(
|
|
||||||
"/test-email",
|
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.monitorController.sendTestEmail
|
|
||||||
);
|
|
||||||
|
|
||||||
// Individual monitor CRUD routes
|
// Individual monitor CRUD routes
|
||||||
this.router.get("/:monitorId", this.monitorController.getMonitorById);
|
this.router.get("/:monitorId", this.monitorController.getMonitorById);
|
||||||
this.router.put(
|
this.router.put("/:monitorId", verifyTeamAccess(Monitor, "monitorId"), isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor);
|
||||||
"/:monitorId",
|
|
||||||
verifyTeamAccess(Monitor, "monitorId"),
|
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.monitorController.editMonitor
|
|
||||||
);
|
|
||||||
this.router.delete(
|
this.router.delete(
|
||||||
"/:monitorId",
|
"/:monitorId",
|
||||||
verifyOwnership(Monitor, "monitorId"),
|
verifyOwnership(Monitor, "monitorId"),
|
||||||
|
|||||||
@@ -10,16 +10,8 @@ class SettingsRoutes {
|
|||||||
|
|
||||||
initRoutes() {
|
initRoutes() {
|
||||||
this.router.get("/", this.settingsController.getAppSettings);
|
this.router.get("/", this.settingsController.getAppSettings);
|
||||||
this.router.put(
|
this.router.put("/", isAllowed(["admin", "superadmin"]), this.settingsController.updateAppSettings);
|
||||||
"/",
|
this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.settingsController.sendTestEmail);
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.settingsController.updateAppSettings
|
|
||||||
);
|
|
||||||
this.router.post(
|
|
||||||
"/test-email",
|
|
||||||
isAllowed(["admin", "superadmin"]),
|
|
||||||
this.settingsController.sendTestEmail
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRouter() {
|
getRouter() {
|
||||||
|
|||||||
Reference in new issue
Block a user