reorg to domain and api

This commit is contained in:
Alex Holliday committed 2026-06-09 12:34:15 -07:00
1 parent 0fb210e9e1
commit d022f7d849
190 files changed
+643 -830

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
import { Router, RequestHandler } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import multer from "multer";
import { IAuthController } from "@/api/controllers/authController.js";
const upload = multer();
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", upload.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"]), upload.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, upload.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;
+29
View File
@@ -0,0 +1,29 @@
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;
+24
View File
@@ -0,0 +1,24 @@
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;
+23
View File
@@ -0,0 +1,23 @@
import { IGeoCheckController } from "@/api/controllers/geoCheckController.js";
import { Router } from "express";
class GeoCheckRoutes {
private router: Router;
private geoCheckController: IGeoCheckController;
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;
+30
View File
@@ -0,0 +1,30 @@
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;
+26
View File
@@ -0,0 +1,26 @@
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;
+22
View File
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,29 @@
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;
+64
View File
@@ -0,0 +1,64 @@
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);
this.router.get("/team/groups", this.monitorController.getGroupsByTeamId);
// 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;
@@ -0,0 +1,31 @@
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;
+26
View File
@@ -0,0 +1,26 @@
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;
+26
View File
@@ -0,0 +1,26 @@
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;
+31
View File
@@ -0,0 +1,31 @@
import { IStatusPageController } from "@/api/controllers/statusPageController.js";
import { RequestHandler, Router } from "express";
import multer from "multer";
const upload = multer();
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("/", upload.single("logo"), verifyJWT, this.statusPageController.createStatusPage);
this.router.put("/:id", upload.single("logo"), verifyJWT, this.statusPageController.updateStatusPage);
this.router.get("/:url", verifyStatusPageAccess, this.statusPageController.getStatusPageByUrl);
this.router.delete("/:id", verifyJWT, this.statusPageController.deleteStatusPage);
}
getRouter() {
return this.router;
}
}
export default StatusPageRoutes;
+28
View File
@@ -0,0 +1,28 @@
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;