restore repo structure

This commit is contained in:
Alex Holliday committed 2025-04-20 11:29:53 -07:00
1 parent 6df099a5b6
commit 8b7e3c650b
592 files changed
+37663 -127

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
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;
+59
View File
@@ -0,0 +1,59 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/verifyJWT.js";
import { verifyOwnership } from "../middleware/verifyOwnership.js";
import { isAllowed } from "../middleware/isAllowed.js";
import multer from "multer";
import User from "../db/models/User.js";
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.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);
}
getRouter() {
return this.router;
}
}
export default AuthRoutes;
+46
View File
@@ -0,0 +1,46 @@
import { Router } from "express";
import { verifyOwnership } from "../middleware/verifyOwnership.js";
import { isAllowed } from "../middleware/isAllowed.js";
import Monitor from "../db/models/Monitor.js";
class CheckRoutes {
constructor(checkController) {
this.router = Router();
this.checkController = checkController;
this.initRoutes();
}
initRoutes() {
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
this.router.post(
"/:monitorId",
verifyOwnership(Monitor, "monitorId"),
this.checkController.createCheck
);
this.router.delete(
"/:monitorId",
verifyOwnership(Monitor, "monitorId"),
this.checkController.deleteChecks
);
this.router.get("/team/:teamId", this.checkController.getChecksByTeam);
this.router.delete(
"/team/:teamId",
isAllowed(["admin", "superadmin"]),
this.checkController.deleteChecksByTeamId
);
this.router.put(
"/team/ttl",
isAllowed(["admin", "superadmin"]),
this.checkController.updateChecksTTL
);
}
getRouter() {
return this.router;
}
}
export default CheckRoutes;
+28
View File
@@ -0,0 +1,28 @@
import { Router } from "express";
class DiagnosticRoutes {
constructor(diagnosticController) {
this.router = Router();
this.diagnosticController = diagnosticController;
this.initRoutes();
}
initRoutes() {
this.router.get(
"/db/execution-stats/:monitorId",
this.diagnosticController.getDistributedUptimeDbExecutionStats
);
this.router.get(
"/db/get-monitors-by-team-id/:teamId",
this.diagnosticController.getMonitorsByTeamIdExecutionStats
);
this.router.post("/db/stats", this.diagnosticController.getDbStats);
}
getRouter() {
return this.router;
}
}
export default DiagnosticRoutes;
+44
View File
@@ -0,0 +1,44 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/verifyJWT.js";
class DistributedUptimeRoutes {
constructor(distributedUptimeController) {
this.router = Router();
this.distributedUptimeController = distributedUptimeController;
this.initRoutes();
}
initRoutes() {
this.router.post("/callback", this.distributedUptimeController.resultsCallback);
this.router.get(
"/monitors/:teamId/initial",
verifyJWT,
this.distributedUptimeController.getDistributedUptimeMonitors
);
this.router.get(
"/monitors/:teamId",
this.distributedUptimeController.subscribeToDistributedUptimeMonitors
);
this.router.get(
"/monitors/details/:monitorId/initial",
verifyJWT,
this.distributedUptimeController.getDistributedUptimeMonitorDetails
);
this.router.get(
"/monitors/details/public/:monitorId/initial",
this.distributedUptimeController.getDistributedUptimeMonitorDetails
);
this.router.get(
"/monitors/details/:monitorId",
this.distributedUptimeController.subscribeToDistributedUptimeMonitorDetails
);
}
getRouter() {
return this.router;
}
}
export default DistributedUptimeRoutes;
+29
View File
@@ -0,0 +1,29 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/verifyJWT.js";
import { isAllowed } from "../middleware/isAllowed.js";
class InviteRoutes {
constructor(inviteController) {
this.router = Router();
this.inviteController = inviteController;
this.initRoutes();
}
initRoutes() {
this.router.post(
"/",
isAllowed(["admin", "superadmin"]),
verifyJWT,
this.inviteController.getInviteToken
);
this.router.post("/send", this.inviteController.sendInviteEmail);
this.router.post("/verify", this.inviteController.inviteVerifyController);
}
getRouter() {
return this.router;
}
}
export default InviteRoutes;
+37
View File
@@ -0,0 +1,37 @@
import { Router } from "express";
import { verifyOwnership } from "../middleware/verifyOwnership.js";
import Monitor from "../db/models/Monitor.js";
class MaintenanceWindowRoutes {
constructor(maintenanceWindowController) {
this.router = Router();
this.maintenanceWindowController = maintenanceWindowController;
this.initRoutes();
}
initRoutes() {
this.router.post("/", this.maintenanceWindowController.createMaintenanceWindows);
this.router.get(
"/monitor/:monitorId",
verifyOwnership(Monitor, "monitorId"),
this.maintenanceWindowController.getMaintenanceWindowsByMonitorId
);
this.router.get(
"/team/",
this.maintenanceWindowController.getMaintenanceWindowsByTeamId
);
this.router.get("/:id", this.maintenanceWindowController.getMaintenanceWindowById);
this.router.put("/:id", this.maintenanceWindowController.editMaintenanceWindow);
this.router.delete("/:id", this.maintenanceWindowController.deleteMaintenanceWindow);
}
getRouter() {
return this.router;
}
}
export default MaintenanceWindowRoutes;
+103
View File
@@ -0,0 +1,103 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
import { fetchMonitorCertificate } from "../controllers/controllerUtils.js";
class MonitorRoutes {
constructor(monitorController) {
this.router = Router();
this.monitorController = monitorController;
this.initRoutes();
}
initRoutes() {
this.router.get("/", this.monitorController.getAllMonitors);
this.router.get("/uptime", this.monitorController.getAllMonitorsWithUptimeStats);
this.router.get("/stats/:monitorId", this.monitorController.getMonitorStatsById);
this.router.get(
"/hardware/details/:monitorId",
this.monitorController.getHardwareDetailsById
);
this.router.get(
"/uptime/details/:monitorId",
this.monitorController.getUptimeDetailsById
);
this.router.get("/certificate/:monitorId", (req, res, next) => {
this.monitorController.getMonitorCertificate(
req,
res,
next,
fetchMonitorCertificate
);
});
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.get("/team/:teamId", this.monitorController.getMonitorsByTeamId);
this.router.get(
"/summary/team/:teamId",
this.monitorController.getMonitorsAndSummaryByTeamId
);
this.router.get(
"/team/:teamId/with-checks",
this.monitorController.getMonitorsWithChecksByTeamId
);
this.router.get(
"/resolution/url",
isAllowed(["admin", "superadmin"]),
this.monitorController.checkEndpointResolution
);
this.router.delete(
"/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.deleteMonitor
);
this.router.post(
"/",
isAllowed(["admin", "superadmin"]),
this.monitorController.createMonitor
);
this.router.put(
"/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.editMonitor
);
this.router.delete(
"/",
isAllowed(["superadmin"]),
this.monitorController.deleteAllMonitors
);
this.router.post(
"/pause/:monitorId",
isAllowed(["admin", "superadmin"]),
this.monitorController.pauseMonitor
);
this.router.post(
"/demo",
isAllowed(["admin", "superadmin"]),
this.monitorController.addDemoMonitors
);
this.router.post(
"/bulk",
isAllowed(["admin", "superadmin"]),
this.monitorController.createBulkMonitors
);
this.router.post("/seed", isAllowed(["superadmin"]), this.monitorController.seedDb);
}
getRouter() {
return this.router;
}
}
export default MonitorRoutes;
+30
View File
@@ -0,0 +1,30 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/verifyJWT.js";
class NotificationRoutes {
constructor(notificationController) {
this.router = Router();
this.notificationController = notificationController;
this.initializeRoutes();
}
initializeRoutes() {
this.router.use(verifyJWT);
this.router.post(
"/trigger",
this.notificationController.triggerNotification
);
this.router.post(
"/test-webhook",
this.notificationController.testWebhook
);
}
getRouter() {
return this.router;
}
}
export default NotificationRoutes;
+52
View File
@@ -0,0 +1,52 @@
import { Router } from "express";
import { isAllowed } from "../middleware/isAllowed.js";
class QueueRoutes {
constructor(queueController) {
this.router = Router();
this.queueController = queueController;
this.initRoutes();
}
initRoutes() {
this.router.get(
"/metrics",
isAllowed(["admin", "superadmin"]),
this.queueController.getMetrics
);
this.router.get(
"/jobs",
isAllowed(["admin", "superadmin"]),
this.queueController.getJobs
);
this.router.post(
"/jobs",
isAllowed(["admin", "superadmin"]),
this.queueController.addJob
);
this.router.post(
"/obliterate",
isAllowed(["admin", "superadmin"]),
this.queueController.obliterateQueue
);
this.router.post(
"/flush",
isAllowed(["admin", "superadmin"]),
this.queueController.flushQueue
);
this.router.get(
"/health",
isAllowed(["admin", "superadmin"]),
this.queueController.checkQueueHealth
);
}
getRouter() {
return this.router;
}
}
export default QueueRoutes;
+25
View File
@@ -0,0 +1,25 @@
import { Router } from "express";
import { isAllowed } from "../middleware/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(["superadmin"]),
this.settingsController.updateAppSettings
);
}
getRouter() {
return this.router;
}
}
export default SettingsRoutes;
+46
View File
@@ -0,0 +1,46 @@
import { Router } from "express";
import { verifyJWT } from "../middleware/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/:teamId",
verifyJWT,
this.statusPageController.getStatusPagesByTeamId
);
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
this.router.get(
"/distributed/:url",
this.statusPageController.getDistributedStatusPageByUrl
);
this.router.post(
"/",
upload.single("logo"),
verifyJWT,
this.statusPageController.createStatusPage
);
this.router.put(
"/",
upload.single("logo"),
verifyJWT,
this.statusPageController.updateStatusPage
);
this.router.delete("/:url(*)", verifyJWT, this.statusPageController.deleteStatusPage);
}
getRouter() {
return this.router;
}
}
export default StatusPageRoutes;