From b708e83ccef253e4888331efc669cedaa23c5654 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Feb 2026 15:11:37 -0800 Subject: [PATCH] add TODOs --- server/src/controllers/monitorController.ts | 6 +++++- server/src/repositories/monitors/IMonitorsRepository.ts | 1 + server/src/repositories/monitors/MongoMonitorsRepository.ts | 1 + server/src/routes/monitorRoute.ts | 5 +++++ server/src/service/business/monitorService.ts | 2 ++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/controllers/monitorController.ts b/server/src/controllers/monitorController.ts index df1945fcc..847c73731 100644 --- a/server/src/controllers/monitorController.ts +++ b/server/src/controllers/monitorController.ts @@ -172,9 +172,10 @@ class MonitorController { } }; + // TODO rename to Import, change to accept JSON createBulkMonitors = async (req: Request, res: Response, next: NextFunction) => { try { - const userId = req.user?.id; + const userId = req.user?.id; // TODO use the correct helper function if (!userId) { throw new AppError({ message: "User ID is required", status: 400 }); } @@ -182,6 +183,9 @@ class MonitorController { const teamId = requireTeamId(req?.user?.teamId); const data = req.body; + + // TODO extract JSON, validate? + const monitors = await this.monitorService.createBulkMonitors(data, userId, teamId); return res.status(200).json({ diff --git a/server/src/repositories/monitors/IMonitorsRepository.ts b/server/src/repositories/monitors/IMonitorsRepository.ts index 63940f591..1cbb1d3fc 100644 --- a/server/src/repositories/monitors/IMonitorsRepository.ts +++ b/server/src/repositories/monitors/IMonitorsRepository.ts @@ -17,6 +17,7 @@ export interface SummaryConfig { export interface IMonitorsRepository { // create create(monitor: Monitor, teamId: string, userId: string): Promise; + // TODO rename createMonitors createBulkMonitors(monitors: Monitor[]): Promise; // single fetch findById(monitorId: string, teamId: string): Promise; diff --git a/server/src/repositories/monitors/MongoMonitorsRepository.ts b/server/src/repositories/monitors/MongoMonitorsRepository.ts index 728d2081f..a8d7d202d 100644 --- a/server/src/repositories/monitors/MongoMonitorsRepository.ts +++ b/server/src/repositories/monitors/MongoMonitorsRepository.ts @@ -12,6 +12,7 @@ class MongoMonitorsRepository implements IMonitorsRepository { return this.toEntity(saved); }; + // TODO rename to createMonitors, must accept JSON createBulkMonitors = async (monitors: Monitor[]): Promise => { if (!monitors.length) { return []; diff --git a/server/src/routes/monitorRoute.ts b/server/src/routes/monitorRoute.ts index e958f3664..5458c3c31 100755 --- a/server/src/routes/monitorRoute.ts +++ b/server/src/routes/monitorRoute.ts @@ -26,6 +26,7 @@ class MonitorRoutes { // Hardware routes this.router.get("/hardware/details/:monitorId", this.monitorController.getHardwareDetailsById); + // PageSpeed routes this.router.get("/pagespeed/details/:monitorId", this.monitorController.getPageSpeedDetailsById); @@ -44,7 +45,11 @@ class MonitorRoutes { // Other static routes this.router.post("/demo", isAllowed(["admin", "superadmin"]), this.monitorController.addDemoMonitors); this.router.get("/export/json", isAllowed(["admin", "superadmin"]), this.monitorController.exportMonitorsToJSON); + + // TODO this needs to be modified to accept JSON, change to /import this.router.post("/bulk", isAllowed(["admin", "superadmin"]), upload.single("csvFile"), this.monitorController.createBulkMonitors); + // END TODO + this.router.post("/test-email", isAllowed(["admin", "superadmin"]), this.monitorController.sendTestEmail); this.router.get("/games", this.monitorController.getAllGames); diff --git a/server/src/service/business/monitorService.ts b/server/src/service/business/monitorService.ts index 8ea83c509..8c2f9e111 100644 --- a/server/src/service/business/monitorService.ts +++ b/server/src/service/business/monitorService.ts @@ -29,6 +29,7 @@ export interface IMonitorService { // create createMonitor(teamId: string, userId: string, body: Monitor): Promise; + // TODO rename createMonitors createBulkMonitors(monitors: Array, userId: string, teamId: string): Promise; addDemoMonitors(args: { userId: string; teamId: string }): Promise; @@ -158,6 +159,7 @@ export class MonitorService implements IMonitorService { }; createBulkMonitors = async (monitors: Array, userId: string, teamId: string): Promise => { + // TDO rename createMonitors, change to accept JSON const createdMonitors = await this.monitorsRepository.createBulkMonitors(monitors); if (!monitors || monitors.length === 0) { throw new AppError({ message: "Failed to create monitors", status: 500, service: SERVICE_NAME, method: "createBulkMonitors" });