restore repo structure
This commit is contained in:
1 parent
6df099a5b6
commit
8b7e3c650b
592 files changed
+37663
-127
No files matched your search
Executable
+38
@@ -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;
|
||||
Executable
+59
@@ -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;
|
||||
Executable
+46
@@ -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;
|
||||
Executable
+28
@@ -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;
|
||||
Executable
+44
@@ -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;
|
||||
Executable
+29
@@ -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;
|
||||
Executable
+37
@@ -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;
|
||||
Executable
+103
@@ -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;
|
||||
Executable
+30
@@ -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;
|
||||
Executable
+52
@@ -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;
|
||||
Executable
+25
@@ -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;
|
||||
Executable
+46
@@ -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;
|
||||
Reference in new issue
Block a user