initial commit

This commit is contained in:
Alex Holliday committed 2025-11-13 13:47:26 -08:00
1 parent 7cb985116e
commit 75acf7b38f
955 files changed
+37333 -87054

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import { Router } from "express";
import { AuthController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { validateBody } from "@/middleware/validation.js";
import {
registerSchema,
registerWithInviteSchema,
loginSchema,
} from "@/validation/index.js";
class AuthRoutes {
private controller: AuthController;
private router: Router;
constructor(authController: AuthController) {
this.controller = authController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/register",
validateBody(registerSchema),
this.controller.register
);
this.router.post(
"/register/invite/:token",
validateBody(registerWithInviteSchema),
this.controller.registerWithInvite
);
this.router.post(
"/login",
validateBody(loginSchema),
this.controller.login
);
this.router.post("/logout", this.controller.logout);
this.router.get("/me", verifyToken, this.controller.me);
this.router.post("/cleanup", this.controller.cleanup);
this.router.post("/cleanup-monitors", this.controller.cleanMonitors);
};
getRouter() {
return this.router;
}
}
export default AuthRoutes;
+36
View File
@@ -0,0 +1,36 @@
import { Router } from "express";
import { ChecksController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { validateQuery } from "@/middleware/validation.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import { checksStatusIdQuerySchema } from "@/validation/index.js";
class CheckRoutes {
private controller: ChecksController;
private router: Router;
constructor(checksController: ChecksController) {
this.controller = checksController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.get(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.checks.read]),
validateQuery(checksStatusIdQuerySchema),
this.controller.getChecksByStatus
);
};
getRouter() {
return this.router;
}
}
export default CheckRoutes;
+38
View File
@@ -0,0 +1,38 @@
import { Router } from "express";
import { DiagnosticController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
class DiagnosticRoutes {
private router;
private controller;
constructor(diagnosticController: DiagnosticController) {
this.router = Router();
this.controller = diagnosticController;
this.initRoutes();
}
initRoutes = () => {
this.router.get(
"/logs",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.diagnostic.read]),
this.controller.getLogs
);
this.router.get(
"/jobs",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.diagnostic.read]),
this.controller.getJobs
);
};
getRouter() {
return this.router;
}
}
export default DiagnosticRoutes;
+48
View File
@@ -0,0 +1,48 @@
import { Router } from "express";
import { ChecksController, IncidentsController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { validateQuery, validateBody } from "@/middleware/validation.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import {
getIncidentsQuerySchema,
patchIncidentsBodySchema,
} from "@/validation/index.js";
class IncidentsRoutes {
private controller: IncidentsController;
private router: Router;
constructor(incidentsController: IncidentsController) {
this.controller = incidentsController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.get(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.incidents.read]),
validateQuery(getIncidentsQuerySchema),
this.controller.getIncidents
);
this.router.patch(
"/:id/resolve",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.incidents.update]),
validateBody(patchIncidentsBodySchema),
this.controller.resolveIncident
);
};
getRouter() {
return this.router;
}
}
export default IncidentsRoutes;
+17
View File
@@ -0,0 +1,17 @@
import RoleRoutes from "./roles.js";
export { default as AuthRoutes } from "./auth.js";
export { default as InviteRoutes } from "./invite.js";
export { default as MaintenanceRoutes } from "./maintenance.js";
export { default as MonitorRoutes } from "./monitors.js";
export { default as NotificationChannelRoutes } from "./notificationChannels.js";
export { default as QueueRoutes } from "./queue.js";
export { default as TeamRoutes } from "./team.js";
export { default as RoleRoutes } from "./roles.js";
export { default as TeamMemberRoutes } from "./teamMembers.js";
export { default as ChecksRoutes } from "./checks.js";
export { default as StatusPageRoutes } from "./statusPages.js";
export { default as DiagnosticRoutes } from "./diagnostic.js";
export { default as RecoveryRoutes } from "./recovery.js";
export { default as ProfileRoutes } from "./profile.js";
export { default as IncidentsRoutes } from "./incidents.js";
+52
View File
@@ -0,0 +1,52 @@
import { Router } from "express";
import { InviteController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import { validateBody } from "@/middleware/validation.js";
import { inviteSchema } from "@/validation/index.js";
class InviteRoutes {
private router;
private controller;
constructor(inviteController: InviteController) {
this.router = Router();
this.controller = inviteController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
validateBody(inviteSchema),
verifyOrgPermission([PERMISSIONS.invite.write]),
this.controller.create
);
this.router.get(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.invite.read]),
this.controller.getAll
);
this.router.get("/:id", verifyToken, this.controller.get);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.invite.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default InviteRoutes;
+72
View File
@@ -0,0 +1,72 @@
import { Router } from "express";
import { MaintenanceController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyTeamPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
class MaintenanceRoutes {
private router;
private controller;
constructor(maintenanceController: MaintenanceController) {
this.router = Router();
this.controller = maintenanceController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.write]),
this.controller.create
);
this.router.get(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.read]),
this.controller.getAll
);
this.router.patch(
"/:id/active",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.update]),
this.controller.toggleActive
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.update]),
this.controller.update
);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.read]),
this.controller.get
);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.maintenance.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default MaintenanceRoutes;
+103
View File
@@ -0,0 +1,103 @@
import { Router } from "express";
import { MonitorController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyTeamPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import { validateBody, validateQuery } from "@/middleware/validation.js";
import {
monitorSchema,
monitorIdChecksQuerySchema,
monitorPatchSchema,
monitorAllEmbedChecksQuerySchema,
} from "@/validation/index.js";
import { verify } from "node:crypto";
class MonitorRoutes {
private router;
private controller;
constructor(monitorController: MonitorController) {
this.router = Router();
this.controller = monitorController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.write]),
validateBody(monitorSchema),
this.controller.create
);
this.router.get(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.read]),
validateQuery(monitorAllEmbedChecksQuerySchema),
this.controller.getAll
);
this.router.get(
"/:id/checks",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.read]),
validateQuery(monitorIdChecksQuerySchema),
this.controller.getChecks
);
this.router.post(
"/:id/notifications/test",
verifyToken,
addUserContext,
verifyTeamPermission([
PERMISSIONS.monitors.read,
PERMISSIONS.notifications.read,
]),
this.controller.testNotifications
);
this.router.patch(
"/:id/active",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.write]),
this.controller.toggleActive
);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.read]),
this.controller.get
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.write]),
validateBody(monitorPatchSchema),
this.controller.update
);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.monitors.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default MonitorRoutes;
+87
View File
@@ -0,0 +1,87 @@
import { Router } from "express";
import { NotificationChannelController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyTeamPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import { validateBody, validateQuery } from "@/middleware/validation.js";
import {
notificationChannelSchema,
notificationPatchSchema,
} from "@/validation/index.js";
class NotificationChannelRoutes {
private router;
private controller;
constructor(notificationChannelController: NotificationChannelController) {
this.router = Router();
this.controller = notificationChannelController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.write]),
validateBody(notificationChannelSchema),
this.controller.create
);
this.router.get(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.read]),
this.controller.getAll
);
this.router.patch(
"/:id/active",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.write]),
this.controller.toggleActive
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.update]),
validateBody(notificationPatchSchema),
this.controller.update
);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.read]),
this.controller.get
);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.notifications.delete]),
this.controller.delete
);
this.router.post(
"/test",
verifyToken,
addUserContext,
validateBody(notificationChannelSchema),
verifyTeamPermission([PERMISSIONS.notifications.write]),
this.controller.test
);
};
getRouter() {
return this.router;
}
}
export default NotificationChannelRoutes;
+34
View File
@@ -0,0 +1,34 @@
import { Router } from "express";
import { ProfileController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { validateBody } from "@/middleware/validation.js";
import { profileSchema } from "@/validation/index.js";
class ProfileRoutes {
private router;
private controller;
constructor(profileController: ProfileController) {
this.router = Router();
this.controller = profileController;
this.initRoutes();
}
initRoutes = () => {
this.router.get("/", verifyToken, addUserContext, this.controller.get);
this.router.patch(
"/",
verifyToken,
addUserContext,
validateBody(profileSchema),
this.controller.update
);
};
getRouter() {
return this.router;
}
}
export default ProfileRoutes;
+24
View File
@@ -0,0 +1,24 @@
import { QueueController } from "@/controllers/index.js";
import { Router } from "express";
class QueueRoutes {
private router;
private controller;
constructor(queueController: QueueController) {
this.router = Router();
this.controller = queueController;
this.initRoutes();
}
initRoutes() {
this.router.get("/jobs", this.controller.getJobs);
this.router.get("/metrics", this.controller.getMetrics);
this.router.post("/flush", this.controller.flush);
}
getRouter() {
return this.router;
}
}
export default QueueRoutes;
+33
View File
@@ -0,0 +1,33 @@
import { Router } from "express";
import { RecoveryController } from "@/controllers/index.js";
import { validateBody } from "@/middleware/validation.js";
import { recoverySchema, resetPasswordSchema } from "@/validation/index.js";
class RecoveryRoutes {
private router;
private controller;
constructor(recoveryController: RecoveryController) {
this.router = Router();
this.controller = recoveryController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
validateBody(recoverySchema),
this.controller.requestRecovery
);
this.router.post(
"/reset",
validateBody(resetPasswordSchema),
this.controller.resetPassword
);
};
getRouter() {
return this.router;
}
}
export default RecoveryRoutes;
+48
View File
@@ -0,0 +1,48 @@
import { Router } from "express";
import { RoleController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
class RoleRoutes {
private controller: RoleController;
private router: Router;
constructor(roleController: RoleController) {
this.controller = roleController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.get(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.roles.read]),
this.controller.getAll
);
this.router.get(
"/team/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.roles.read]),
this.controller.getTeam
);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.roles.read]),
this.controller.get
);
};
getRouter() {
return this.router;
}
}
export default RoleRoutes;
+70
View File
@@ -0,0 +1,70 @@
import { Router } from "express";
import { StatusPageController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { verifyTeamPermission } from "@/middleware/VerifyPermission.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
import { validateBody } from "@/middleware/validation.js";
import { statusPageSchema } from "@/validation/index.js";
class StatusPageRoutes {
private router;
private controller;
constructor(statusPageController: StatusPageController) {
this.router = Router();
this.controller = statusPageController;
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.statusPages.write]),
validateBody(statusPageSchema),
this.controller.create
);
this.router.get(
"/",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.statusPages.read]),
this.controller.getAll
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.statusPages.update]),
validateBody(statusPageSchema.partial()),
this.controller.update
);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.statusPages.read]),
this.controller.get
);
this.router.get("/public/:url", this.controller.getPublic);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyTeamPermission([PERMISSIONS.statusPages.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default StatusPageRoutes;
+60
View File
@@ -0,0 +1,60 @@
import { Router } from "express";
import { TeamController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
class TeamRoutes {
private controller: TeamController;
private router: Router;
constructor(teamController: TeamController) {
this.controller = teamController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.write]),
this.controller.create
);
this.router.get("/", verifyToken, this.controller.getOrg);
this.router.get("/joined", verifyToken, this.controller.getJoined);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.read]),
this.controller.get
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.write]),
this.controller.update
);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default TeamRoutes;
+59
View File
@@ -0,0 +1,59 @@
import { Router } from "express";
import { TeamMemberController } from "@/controllers/index.js";
import { verifyToken } from "@/middleware/VerifyToken.js";
import { addUserContext } from "@/middleware/AddUserContext.js";
import { verifyOrgPermission } from "@/middleware/VerifyPermission.js";
import { PERMISSIONS } from "@/services/business/AuthService.js";
class TeamMemberRoutes {
private controller: TeamMemberController;
private router: Router;
constructor(teamMemberController: TeamMemberController) {
this.controller = teamMemberController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.post(
"/",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.write]),
this.controller.create
);
this.router.get("/", verifyToken, addUserContext, this.controller.getAll);
this.router.get(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.read]),
this.controller.get
);
this.router.patch(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.write]),
this.controller.update
);
this.router.delete(
"/:id",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.teams.delete]),
this.controller.delete
);
};
getRouter() {
return this.router;
}
}
export default TeamMemberRoutes;
@@ -1,33 +0,0 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/verifyJWT.js";
import { isAllowed } from "../middleware/isAllowed.js";
class AnnouncementRoutes {
constructor(controller) {
this.router = Router();
this.announcementController = controller;
this.initRoutes();
}
initRoutes() {
/**
* @route POST /
* @desc Create a new announcement
* @access Private (Requires JWT verification)
*/
this.router.post("/", verifyJWT, isAllowed(["admin", "superadmin"]), this.announcementController.createAnnouncement);
/**
* @route GET /
* @desc Get announcements
* @access Public
*/
this.router.get("/", this.announcementController.getAnnouncement);
}
getRouter() {
return this.router;
}
}
export default AnnouncementRoutes;
-39
View File
@@ -1,39 +0,0 @@
import { Router } from "express";
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
import multer from "multer";
const upload = multer();
class AuthRoutes {
constructor(authController) {
this.router = Router();
this.authController = authController;
this.initRoutes();
}
initRoutes() {
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.get("/users/:userId", verifyJWT, isAllowed(["superadmin"]), this.authController.getUserById);
this.router.put("/users/:userId", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserById);
this.router.put("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserPasswordById);
this.router.put("/user", verifyJWT, upload.single("profileImage"), this.authController.editUser);
this.router.delete("/user", verifyJWT, this.authController.deleteUser);
}
getRouter() {
return this.router;
}
}
export default AuthRoutes;
-31
View File
@@ -1,31 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class CheckRoutes {
constructor(checkController) {
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.put("/team/ttl", isAllowed(["admin", "superadmin"]), this.checkController.updateChecksTTL);
this.router.delete("/team", isAllowed(["admin", "superadmin"]), this.checkController.deleteChecksByTeamId);
this.router.put("/check/:checkId", this.checkController.ackCheck);
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
this.router.delete("/:monitorId", this.checkController.deleteChecks);
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
}
getRouter() {
return this.router;
}
}
export default CheckRoutes;
-20
View File
@@ -1,20 +0,0 @@
import { Router } from "express";
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class DiagnosticRoutes {
constructor(diagnosticController) {
this.router = Router();
this.diagnosticController = diagnosticController;
this.initRoutes();
}
initRoutes() {
this.router.get("/system", verifyJWT, isAllowed(["admin", "superadmin"]), this.diagnosticController.getSystemStats);
}
getRouter() {
return this.router;
}
}
export default DiagnosticRoutes;
-23
View File
@@ -1,23 +0,0 @@
import { Router } from "express";
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class InviteRoutes {
constructor(inviteController) {
this.router = Router();
this.inviteController = inviteController;
this.initRoutes();
}
initRoutes() {
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;
-18
View File
@@ -1,18 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class LogRoutes {
constructor(logController) {
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;
@@ -1,25 +0,0 @@
import { Router } from "express";
class MaintenanceWindowRoutes {
constructor(maintenanceWindowController) {
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.put("/:id", this.mwController.editMaintenanceWindow);
this.router.delete("/:id", this.mwController.deleteMaintenanceWindow);
}
getRouter() {
return this.router;
}
}
export default MaintenanceWindowRoutes;
-61
View File
@@ -1,61 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
import multer from "multer";
import { fetchMonitorCertificate } from "../../controllers/v1/controllerUtils.js";
const upload = multer({
storage: multer.memoryStorage(), // Store file in memory as Buffer
});
class MonitorRoutes {
constructor(monitorController) {
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/summary", this.monitorController.getMonitorsAndSummaryByTeamId);
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);
// 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("/certificate/:monitorId", (req, res, next) => {
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);
// 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("/bulk", isAllowed(["admin", "superadmin"]), upload.single("csvFile"), this.monitorController.createBulkMonitors);
this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.monitorController.sendTestEmail);
this.router.get("/games", this.monitorController.getAllGames);
// Individual monitor CRUD routes
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.put("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.editMonitor);
this.router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), this.monitorController.deleteMonitor);
}
getRouter() {
return this.router;
}
}
export default MonitorRoutes;
-27
View File
@@ -1,27 +0,0 @@
import { Router } from "express";
class NotificationRoutes {
constructor(notificationController) {
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.put("/:id", this.notificationController.editNotification);
}
getRouter() {
return this.router;
}
}
export default NotificationRoutes;
-24
View File
@@ -1,24 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class QueueRoutes {
constructor(queueController) {
this.router = Router();
this.queueController = queueController;
this.initRoutes();
}
initRoutes() {
this.router.get("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.getJobs);
this.router.post("/jobs", isAllowed(["admin", "superadmin"]), this.queueController.addJob);
this.router.get("/metrics", isAllowed(["admin", "superadmin"]), 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() {
return this.router;
}
}
export default QueueRoutes;
-22
View File
@@ -1,22 +0,0 @@
import { Router } from "express";
import { isAllowed } from "../../middleware/v1/isAllowed.js";
class SettingsRoutes {
constructor(settingsController) {
this.router = Router();
this.settingsController = settingsController;
this.initRoutes();
}
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);
}
getRouter() {
return this.router;
}
}
export default SettingsRoutes;
-29
View File
@@ -1,29 +0,0 @@
import { Router } from "express";
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
import multer from "multer";
const upload = multer();
class StatusPageRoutes {
constructor(statusPageController) {
this.router = Router();
this.statusPageController = statusPageController;
this.initRoutes();
}
initRoutes() {
this.router.get("/", this.statusPageController.getStatusPage);
this.router.get("/team", verifyJWT, this.statusPageController.getStatusPagesByTeamId);
this.router.post("/", upload.single("logo"), verifyJWT, this.statusPageController.createStatusPage);
this.router.put("/", upload.single("logo"), verifyJWT, this.statusPageController.updateStatusPage);
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.delete("/:url(*)", verifyJWT, this.statusPageController.deleteStatusPage);
}
getRouter() {
return this.router;
}
}
export default StatusPageRoutes;
-33
View File
@@ -1,33 +0,0 @@
import { Router } from "express";
import express from "express";
import AuthController from "../../controllers/v2/AuthController.js";
import { verifyToken } from "../../middleware/v2/VerifyToken.js";
const router = express.Router();
class AuthRoutes {
private controller: AuthController;
private router: Router;
constructor(authController: AuthController) {
this.controller = authController;
this.router = Router();
this.initRoutes();
}
initRoutes = () => {
this.router.post("/register", this.controller.register);
this.router.post("/register/invite/:token", this.controller.registerWithInvite);
this.router.post("/login", this.controller.login);
this.router.post("/logout", this.controller.logout);
this.router.get("/me", verifyToken, this.controller.me);
this.router.post("/cleanup", this.controller.cleanup);
this.router.post("/cleanup-monitors", this.controller.cleanMonitors);
};
getRouter() {
return this.router;
}
}
export default AuthRoutes;
-30
View File
@@ -1,30 +0,0 @@
import { Router } from "express";
import InviteController from "../../controllers/v2/InviteController.js";
import { verifyToken } from "../../middleware/v2/VerifyToken.js";
import { verifyPermission } from "../../middleware/v2/VerifyPermissions.js";
class InviteRoutes {
private router;
private controller;
constructor(inviteController: InviteController) {
this.router = Router();
this.controller = inviteController;
this.initRoutes();
}
initRoutes = () => {
this.router.post("/", verifyToken, verifyPermission(["invite.create"]), this.controller.create);
this.router.get("/", verifyToken, verifyPermission(["invite.view"]), this.controller.getAll);
this.router.get("/:token", verifyToken, verifyPermission(["invite.view"]), this.controller.get);
this.router.delete("/:id", verifyToken, verifyPermission(["invite.delete"]), this.controller.delete);
};
getRouter() {
return this.router;
}
}
export default InviteRoutes;
-34
View File
@@ -1,34 +0,0 @@
import { Router } from "express";
import MaintenanceController from "../../controllers/v2/MaintenanceController.js";
import { verifyToken } from "../../middleware/v2/VerifyToken.js";
import { verifyPermission } from "../../middleware/v2/VerifyPermissions.js";
class MaintenanceRoutes {
private router;
private controller;
constructor(maintenanceController: MaintenanceController) {
this.router = Router();
this.controller = maintenanceController;
this.initRoutes();
}
initRoutes = () => {
this.router.post("/", verifyToken, verifyPermission(["maintenance.create"]), this.controller.create);
this.router.get("/", verifyToken, verifyPermission(["maintenance.view"]), this.controller.getAll);
this.router.patch("/:id/active", verifyToken, verifyPermission(["maintenance.update"]), this.controller.toggleActive);
this.router.patch("/:id", verifyToken, verifyPermission(["maintenance.update"]), this.controller.update);
this.router.get("/:id", verifyToken, verifyPermission(["maintenance.view"]), this.controller.get);
this.router.delete("/:id", verifyToken, verifyPermission(["maintenance.delete"]), this.controller.delete);
};
getRouter() {
return this.router;
}
}
export default MaintenanceRoutes;
-36
View File
@@ -1,36 +0,0 @@
import { Router } from "express";
import MonitorController from "../../controllers/v2/MonitorController.js";
import { verifyToken } from "../../middleware/v2/VerifyToken.js";
import { verifyPermission } from "../../middleware/v2/VerifyPermissions.js";
class MonitorRoutes {
private router;
private controller;
constructor(monitorController: MonitorController) {
this.router = Router();
this.controller = monitorController;
this.initRoutes();
}
initRoutes = () => {
this.router.post("/", verifyToken, verifyPermission(["monitors.create"]), this.controller.create);
this.router.get("/", verifyToken, verifyPermission(["monitors.view"]), this.controller.getAll);
this.router.get("/:id/checks", verifyToken, verifyPermission(["monitors.view"]), this.controller.getChecks);
this.router.patch("/:id/active", verifyToken, verifyPermission(["monitors.update"]), this.controller.toggleActive);
this.router.get("/:id", verifyToken, verifyPermission(["monitors.view"]), this.controller.get);
this.router.patch("/:id", verifyToken, verifyPermission(["monitors.update"]), this.controller.update);
this.router.delete("/:id", verifyToken, verifyPermission(["monitors.delete"]), this.controller.delete);
};
getRouter() {
return this.router;
}
}
export default MonitorRoutes;
@@ -1,34 +0,0 @@
import { Router } from "express";
import NotificationController from "../../controllers/v2/NotificationChannelController.js";
import { verifyToken } from "../../middleware/v2/VerifyToken.js";
import { verifyPermission } from "../../middleware/v2/VerifyPermissions.js";
class NotificationChannelRoutes {
private router;
private controller;
constructor(notificationController: NotificationController) {
this.router = Router();
this.controller = notificationController;
this.initRoutes();
}
initRoutes = () => {
this.router.post("/", verifyToken, verifyPermission(["notifications.create"]), this.controller.create);
this.router.get("/", verifyToken, verifyPermission(["notifications.view"]), this.controller.getAll);
this.router.patch("/:id/active", verifyToken, verifyPermission(["notifications.update"]), this.controller.toggleActive);
this.router.patch("/:id", verifyToken, verifyPermission(["notifications.update"]), this.controller.update);
this.router.get("/:id", verifyToken, verifyPermission(["notifications.view"]), this.controller.get);
this.router.delete("/:id", verifyToken, verifyPermission(["notifications.delete"]), this.controller.delete);
};
getRouter() {
return this.router;
}
}
export default NotificationChannelRoutes;
-24
View File
@@ -1,24 +0,0 @@
import QueueController from "../../controllers/v2/QueueController.js";
import { Router } from "express";
class QueueRoutes {
private router;
private controller;
constructor(queueController: QueueController) {
this.router = Router();
this.controller = queueController;
this.initRoutes();
}
initRoutes() {
this.router.get("/jobs", this.controller.getJobs);
this.router.get("/metrics", this.controller.getMetrics);
this.router.post("/flush", this.controller.flush);
}
getRouter() {
return this.router;
}
}
export default QueueRoutes;