2024-10-15 11:57:37 +08:00
|
|
|
import { Router } from "express";
|
2024-10-15 14:00:24 +08:00
|
|
|
import {
|
2024-11-06 11:17:26 +08:00
|
|
|
getAllMonitors,
|
|
|
|
|
getAllMonitorsWithUptimeStats,
|
|
|
|
|
getMonitorStatsById,
|
|
|
|
|
getMonitorCertificate,
|
|
|
|
|
getMonitorById,
|
|
|
|
|
getMonitorsAndSummaryByTeamId,
|
|
|
|
|
getMonitorsByTeamId,
|
|
|
|
|
createMonitor,
|
|
|
|
|
checkEndpointResolution,
|
|
|
|
|
deleteMonitor,
|
|
|
|
|
deleteAllMonitors,
|
|
|
|
|
editMonitor,
|
|
|
|
|
pauseMonitor,
|
|
|
|
|
addDemoMonitors,
|
2024-10-15 14:00:24 +08:00
|
|
|
} from "../controllers/monitorController.js";
|
2024-10-15 11:57:37 +08:00
|
|
|
import { isAllowed } from "../middleware/isAllowed.js";
|
2024-10-16 14:17:35 +08:00
|
|
|
import { fetchMonitorCertificate } from "../controllers/controllerUtils.js";
|
2024-10-15 11:57:37 +08:00
|
|
|
|
|
|
|
|
const router = Router();
|
2024-05-21 11:23:39 -07:00
|
|
|
|
2024-10-15 14:00:24 +08:00
|
|
|
router.get("/", getAllMonitors);
|
2024-11-06 11:17:26 +08:00
|
|
|
router.get("/uptime", getAllMonitorsWithUptimeStats);
|
2024-10-15 14:00:24 +08:00
|
|
|
router.get("/stats/:monitorId", getMonitorStatsById);
|
2024-10-16 14:17:35 +08:00
|
|
|
router.get("/certificate/:monitorId", (req, res, next) => {
|
2024-11-06 11:17:26 +08:00
|
|
|
getMonitorCertificate(req, res, next, fetchMonitorCertificate);
|
2024-10-16 14:17:35 +08:00
|
|
|
});
|
2024-10-15 14:00:24 +08:00
|
|
|
router.get("/:monitorId", getMonitorById);
|
|
|
|
|
router.get("/team/summary/:teamId", getMonitorsAndSummaryByTeamId);
|
|
|
|
|
router.get("/team/:teamId", getMonitorsByTeamId);
|
2024-08-27 10:39:55 -07:00
|
|
|
|
2024-10-15 17:20:54 +05:30
|
|
|
router.get(
|
2024-11-06 11:17:26 +08:00
|
|
|
"/resolution/url",
|
|
|
|
|
isAllowed(["admin", "superadmin"]),
|
|
|
|
|
checkEndpointResolution
|
2024-05-24 13:44:42 -07:00
|
|
|
);
|
2024-08-27 10:39:55 -07:00
|
|
|
|
2024-11-06 11:17:26 +08:00
|
|
|
router.delete("/:monitorId", isAllowed(["admin", "superadmin"]), deleteMonitor);
|
|
|
|
|
|
2024-10-15 14:00:24 +08:00
|
|
|
router.post("/", isAllowed(["admin", "superadmin"]), createMonitor);
|
2024-06-18 11:42:25 -07:00
|
|
|
|
2024-10-15 14:00:24 +08:00
|
|
|
router.put("/:monitorId", isAllowed(["admin", "superadmin"]), editMonitor);
|
2024-08-28 15:21:59 -07:00
|
|
|
|
2024-10-15 14:00:24 +08:00
|
|
|
router.delete("/", isAllowed(["superadmin"]), deleteAllMonitors);
|
2024-08-28 15:21:59 -07:00
|
|
|
|
2024-10-16 14:17:35 +08:00
|
|
|
router.post("/pause/:monitorId", isAllowed(["admin", "superadmin"]), pauseMonitor);
|
2024-08-28 15:21:59 -07:00
|
|
|
|
2024-10-15 14:00:24 +08:00
|
|
|
router.post("/demo", isAllowed(["admin", "superadmin"]), addDemoMonitors);
|
2024-09-11 11:03:39 +08:00
|
|
|
|
2024-10-15 11:57:37 +08:00
|
|
|
export default router;
|