- Added a new `/games` route in `monitorRoute.js` to fetch all supported games. - Implemented `getAllGames` method in `monitorController.js` using the `gamedig` library. - Introduced `useFetchMonitorGames` hook in `monitorHooks.js` to fetch game data in the frontend. - Updated `UptimeCreate` page to support game server monitoring: - Added a new monitor type `"game"`. - Dynamically fetches and displays game options using the new `/games` API. - Removed hardcoded `GAMES` object and replaced it with dynamic fetching from the backend. - Updated `NetworkService.js` with a new `getMonitorGames` method for API calls. This update introduces game server monitoring functionality, allowing users to monitor game servers dynamically.
63 lines
2.6 KiB
JavaScript
Executable File
63 lines
2.6 KiB
JavaScript
Executable File
import { Router } from "express";
|
|
import { isAllowed } from "../middleware/isAllowed.js";
|
|
import multer from "multer";
|
|
import { fetchMonitorCertificate } from "../controllers/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);
|
|
|
|
// Uptime routes
|
|
this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById);
|
|
|
|
// Hardware routes
|
|
this.router.get("/hardware/details/:monitorId", this.monitorController.getHardwareDetailsById);
|
|
|
|
// Game routes
|
|
this.router.get("/games", this.monitorController.getAllGames);
|
|
|
|
// 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);
|
|
|
|
// 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;
|