From 7332b152429fd791ff3336dab6c8718215f21caa Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 10:51:06 -0700 Subject: [PATCH 01/20] fix diagnosticSerivce lint error --- server/src/service/business/diagnosticService.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/service/business/diagnosticService.ts b/server/src/service/business/diagnosticService.ts index f9c53f633..45a5592f5 100644 --- a/server/src/service/business/diagnosticService.ts +++ b/server/src/service/business/diagnosticService.ts @@ -24,8 +24,7 @@ export class DiagnosticService implements IDiagnosticService { * Clears performance marks after each measurement to prevent memory leaks. */ const obs = new PerformanceObserver((items) => { - // Get the first entry but we don't need to store it - items.getEntries()[0]; + items.getEntries(); performance.clearMarks(); }); obs.observe({ entryTypes: ["measure"] }); From 6d2008e8d39e98030d2e1e0216e6af1e8df59869 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 10:59:34 -0700 Subject: [PATCH 02/20] geo checks service --- server/src/controllers/geoCheckController.ts | 28 ++++++++++++--- .../src/service/business/geoChecksService.ts | 35 +++++++++++++++---- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/server/src/controllers/geoCheckController.ts b/server/src/controllers/geoCheckController.ts index cfa7fe056..aef0d7e7c 100644 --- a/server/src/controllers/geoCheckController.ts +++ b/server/src/controllers/geoCheckController.ts @@ -1,6 +1,8 @@ import { Request, Response, NextFunction } from "express"; import { getChecksParamValidation, getChecksQueryValidation } from "@/validation/checkValidation.js"; import type { IGeoChecksService } from "@/service/business/geoChecksService.js"; +import { requireTeamId } from "./controllerUtils.js"; +import { AppError } from "@/utils/AppError.js"; const SERVICE_NAME = "geoCheckController"; @@ -18,13 +20,29 @@ class GeoCheckController { getGeoChecksByMonitor = async (req: Request, res: Response, next: NextFunction) => { try { - getChecksParamValidation.parse(req.params); - getChecksQueryValidation.parse(req.query); + const validatedParams = getChecksParamValidation.parse(req.params); + const validatedQuery = getChecksQueryValidation.parse(req.query); + + if (!validatedQuery.continent || validatedQuery.continent.length === 0) { + throw new AppError({ + message: "At least one continent must be specified", + service: SERVICE_NAME, + method: "getGeoChecksByMonitor", + details: { monitorId: validatedParams.monitorId }, + status: 400, + }); + } + + const teamId = requireTeamId(req.user?.teamId); const result = await this.geoChecksService.getGeoChecksByMonitor({ - monitorId: req?.params?.monitorId as string, - query: req?.query, - teamId: req?.user?.teamId as string, + monitorId: validatedParams.monitorId, + teamId: teamId, + sortOrder: validatedQuery.sortOrder, + dateRange: validatedQuery.dateRange, + page: validatedQuery.page, + rowsPerPage: validatedQuery.rowsPerPage, + continent: validatedQuery.continent, }); return res.status(200).json({ diff --git a/server/src/service/business/geoChecksService.ts b/server/src/service/business/geoChecksService.ts index f35826a8f..2793cc542 100644 --- a/server/src/service/business/geoChecksService.ts +++ b/server/src/service/business/geoChecksService.ts @@ -1,5 +1,5 @@ import type { Monitor, GeoCheck } from "@/types/index.js"; -import type { GeoCheckResult } from "@/types/geoCheck.js"; +import type { GeoCheckResult, GeoContinent } from "@/types/geoCheck.js"; import { Types } from "mongoose"; import type { IGeoChecksRepository } from "@/repositories/index.js"; import type { IMonitorsRepository } from "@/repositories/index.js"; @@ -13,7 +13,15 @@ export interface IGeoChecksService { readonly serviceName: string; buildGeoCheck(monitor: Monitor): Promise; createGeoChecks(geoChecks: GeoCheck[]): Promise; - getGeoChecksByMonitor(args: { monitorId: string; query: any; teamId: string }): Promise; + getGeoChecksByMonitor(args: { + monitorId: string; + teamId: string; + sortOrder: string; + dateRange: string; + page?: number; + rowsPerPage?: number; + continent: GeoContinent | GeoContinent[]; + }): Promise; } export class GeoChecksService implements IGeoChecksService { @@ -139,7 +147,23 @@ export class GeoChecksService implements IGeoChecksService { return this.geoChecksRepository.createGeoChecks(geoChecks); }; - getGeoChecksByMonitor = async ({ monitorId, query, teamId }: { monitorId: string; query: any; teamId: string }) => { + getGeoChecksByMonitor = async ({ + monitorId, + teamId, + sortOrder, + dateRange, + page, + rowsPerPage, + continent, + }: { + monitorId: string; + teamId: string; + sortOrder: string; + dateRange: string; + page?: number; + rowsPerPage?: number; + continent: GeoContinent | GeoContinent[]; + }) => { if (!monitorId) { throw new AppError({ message: "No monitor ID in request", @@ -167,10 +191,9 @@ export class GeoChecksService implements IGeoChecksService { }); } - const { sortOrder, dateRange, page, rowsPerPage, continent } = query; const continents = continent ? (Array.isArray(continent) ? continent : [continent]) : undefined; - const parsedPage = page ? parseInt(page) : page; - const parsedRowsPerPage = rowsPerPage ? parseInt(rowsPerPage) : rowsPerPage; + const parsedPage = page || 0; + const parsedRowsPerPage = rowsPerPage || 5; const result = await this.geoChecksRepository.findByMonitorId(monitorId, sortOrder, dateRange, parsedPage, parsedRowsPerPage, continents); return result; }; From 2fb7516ca1cb9aa60e9fe81e4e273477df1587f0 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:00:30 -0700 Subject: [PATCH 03/20] fix return type --- server/src/service/business/geoChecksService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/service/business/geoChecksService.ts b/server/src/service/business/geoChecksService.ts index 2793cc542..315c57858 100644 --- a/server/src/service/business/geoChecksService.ts +++ b/server/src/service/business/geoChecksService.ts @@ -1,7 +1,7 @@ import type { Monitor, GeoCheck } from "@/types/index.js"; import type { GeoCheckResult, GeoContinent } from "@/types/geoCheck.js"; import { Types } from "mongoose"; -import type { IGeoChecksRepository } from "@/repositories/index.js"; +import type { FlatGeoChecksQueryResult, IGeoChecksRepository } from "@/repositories/index.js"; import type { IMonitorsRepository } from "@/repositories/index.js"; import type { IGlobalPingService } from "@/service/infrastructure/globalPingService.js"; import type { ILogger } from "@/utils/logger.js"; @@ -21,7 +21,7 @@ export interface IGeoChecksService { page?: number; rowsPerPage?: number; continent: GeoContinent | GeoContinent[]; - }): Promise; + }): Promise; } export class GeoChecksService implements IGeoChecksService { From 533a8911cd1a85aaf1e8612c64fa6784623891f8 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:01:52 -0700 Subject: [PATCH 04/20] fix errors in inviteService --- server/src/service/business/inviteService.ts | 32 ++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/server/src/service/business/inviteService.ts b/server/src/service/business/inviteService.ts index 9d1cbf59d..7e2b7de52 100644 --- a/server/src/service/business/inviteService.ts +++ b/server/src/service/business/inviteService.ts @@ -2,6 +2,8 @@ import type { Invite, UserRole } from "@/types/index.js"; import { canManageRole } from "@/types/user.js"; import type { IInvitesRepository } from "@/repositories/index.js"; import { AppError } from "@/utils/AppError.js"; +import { ISettingsService } from "../system/settingsService.js"; +import { IEmailService } from "../infrastructure/emailService.js"; const SERVICE_NAME = "inviteService"; @@ -14,8 +16,8 @@ export interface IInviteService { export class InviteService implements IInviteService { static SERVICE_NAME = SERVICE_NAME; - private settingsService: any; - private emailService: any; + private settingsService: ISettingsService; + private emailService: IEmailService; private invitesRepository: IInvitesRepository; constructor({ @@ -24,8 +26,8 @@ export class InviteService implements IInviteService { emailService, }: { invitesRepository: IInvitesRepository; - settingsService: any; - emailService: any; + settingsService: ISettingsService; + emailService: IEmailService; }) { this.invitesRepository = invitesRepository; this.settingsService = settingsService; @@ -57,8 +59,16 @@ export class InviteService implements IInviteService { return inviteToken; }; - sendInviteEmail = async ({ invite, firstName, userRoles }: { invite: Partial; firstName: any; userRoles: UserRole[] }) => { + sendInviteEmail = async ({ invite, firstName, userRoles }: { invite: Partial; firstName: string; userRoles: UserRole[] }) => { const inviteRoles = invite.role ?? []; + if (!invite.email) { + throw new AppError({ + message: "Invite email is required to send an invite", + service: SERVICE_NAME, + method: "sendInviteEmail", + status: 400, + }); + } for (const targetRole of inviteRoles) { const canManage = userRoles.some((actorRole) => canManageRole(actorRole, targetRole)); @@ -66,7 +76,7 @@ export class InviteService implements IInviteService { throw new AppError({ message: "You do not have permission to create this invite", service: SERVICE_NAME, - method: "getInviteToken", + method: "sendInviteEmail", status: 403, }); } @@ -79,6 +89,16 @@ export class InviteService implements IInviteService { name: firstName, link: `${clientHost}/register/${inviteToken.token}`, }); + + if (!html) { + throw new AppError({ + message: "Failed to build invite e-mail... Please verify your settings.", + service: SERVICE_NAME, + method: "sendInviteEmail", + status: 500, + }); + } + const result = await this.emailService.sendEmail(invite.email, "Welcome to Uptime Monitor", html); if (!result) { throw new AppError({ From a4a3249b5bbd2fda8e8be5b3604cbae33dac8186 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:20:22 -0700 Subject: [PATCH 05/20] maintenacne window --- .../maintenanceWindowController.ts | 12 +++- .../business/maintenanceWindowService.ts | 57 ++++++++++++++----- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/server/src/controllers/maintenanceWindowController.ts b/server/src/controllers/maintenanceWindowController.ts index 2e0294db1..edc236fa1 100644 --- a/server/src/controllers/maintenanceWindowController.ts +++ b/server/src/controllers/maintenanceWindowController.ts @@ -21,7 +21,17 @@ class MaintenanceWindowController { try { const validatedBody = createMaintenanceWindowBodyValidation.parse(req.body); const teamId = requireTeamId(req?.user?.teamId); - await this.maintenanceWindowService.createMaintenanceWindow({ teamId, body: validatedBody }); + + const monitorIDs = validatedBody.monitors; + const name = validatedBody.name; + const active = validatedBody.active ? validatedBody.active : true; + const duration = validatedBody.duration; + const durationUnit = validatedBody.durationUnit; + const repeat = validatedBody.repeat; + const start = validatedBody.start; + const end = validatedBody.end; + + await this.maintenanceWindowService.createMaintenanceWindow({ teamId, monitorIDs, name, active, duration, durationUnit, repeat, start, end }); return res.status(200).json({ success: true, diff --git a/server/src/service/business/maintenanceWindowService.ts b/server/src/service/business/maintenanceWindowService.ts index 98b803bd1..50278d215 100644 --- a/server/src/service/business/maintenanceWindowService.ts +++ b/server/src/service/business/maintenanceWindowService.ts @@ -1,11 +1,21 @@ import { IMaintenanceWindowsRepository, IMonitorsRepository } from "@/repositories/index.js"; -import type { MaintenanceWindow } from "@/types/index.js"; +import type { DurationUnit, MaintenanceWindow } from "@/types/index.js"; import { AppError } from "@/utils/AppError.js"; const SERVICE_NAME = "maintenanceWindowService"; export interface IMaintenanceWindowService { - createMaintenanceWindow(params: { teamId: string; body: Partial & { monitors: string[] } }): Promise; + createMaintenanceWindow(params: { + teamId: string; + monitorIDs: string[]; + name: string; + active: boolean; + duration: number; + durationUnit: DurationUnit; + repeat: number; + start: string; + end: string; + }): Promise; getMaintenanceWindowById(params: { id: string; teamId: string }): Promise; getMaintenanceWindowsByTeamId(params: { teamId: string; @@ -40,9 +50,28 @@ export class MaintenanceWindowService implements IMaintenanceWindowService { return MaintenanceWindowService.SERVICE_NAME; } - createMaintenanceWindow = async ({ teamId, body }: { teamId: string; body: any }) => { - const monitorIds = body.monitors; - const monitors = await this.monitorsRepository.findByIds(monitorIds); + createMaintenanceWindow = async ({ + teamId, + monitorIDs, + name, + active, + duration, + durationUnit, + repeat, + start, + end, + }: { + teamId: string; + monitorIDs: string[]; + name: string; + active: boolean; + duration: number; + durationUnit: DurationUnit; + repeat: number; + start: string; + end: string; + }) => { + const monitors = await this.monitorsRepository.findByIds(monitorIDs); const unauthorizedMonitors = monitors.filter((monitor) => monitor.teamId !== teamId); @@ -55,17 +84,17 @@ export class MaintenanceWindowService implements IMaintenanceWindowService { }); } - const dbTransactions = monitorIds.map((monitorId: string) => { + const dbTransactions = monitorIDs.map((monitorId: string) => { return this.maintenanceWindowsRepository.create({ teamId, monitorId, - name: body.name, - active: body.active ? body.active : true, - duration: body.duration, - durationUnit: body.durationUnit, - repeat: body.repeat, - start: body.start, - end: body.end, + name: name, + active: active, + duration: duration, + durationUnit: durationUnit, + repeat: repeat, + start: start, + end: end, }); }); await Promise.all(dbTransactions); @@ -106,7 +135,7 @@ export class MaintenanceWindowService implements IMaintenanceWindowService { return await this.maintenanceWindowsRepository.deleteById(id, teamId); }; - editMaintenanceWindow = async ({ id, teamId, body }: { id: string; teamId: string; body: any }) => { + editMaintenanceWindow = async ({ id, teamId, body }: { id: string; teamId: string; body: Partial }) => { return await this.maintenanceWindowsRepository.updateById(id, teamId, body); }; } From 404bd5d06b24a29e25da90a53f6cf1d6658a4f0a Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:28:53 -0700 Subject: [PATCH 06/20] add interface to AdvancedMathcer, fix type --- .../infrastructure/network/AdvancedMatcher.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/service/infrastructure/network/AdvancedMatcher.ts b/server/src/service/infrastructure/network/AdvancedMatcher.ts index 57bf7022f..f867770f3 100644 --- a/server/src/service/infrastructure/network/AdvancedMatcher.ts +++ b/server/src/service/infrastructure/network/AdvancedMatcher.ts @@ -2,6 +2,10 @@ import { Monitor } from "@/types/monitor.js"; import jmespath from "jmespath"; type JmesPath = typeof jmespath; +export interface IADvancedMatcher { + validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined }; +} + export class AdvancedMatcher { constructor(private jmespath: JmesPath) {} @@ -12,7 +16,7 @@ export class AdvancedMatcher { return String(actual) === expected; // Default } - validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: any } { + validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined } { const { useAdvancedMatching, jsonPath, matchMethod, expectedValue } = monitor; if (!useAdvancedMatching) return { ok: true, message: "Success" }; @@ -35,10 +39,10 @@ export class AdvancedMatcher { }; } - const isFalsey = dataToValidate === false || dataToValidate === "false" || dataToValidate === undefined || dataToValidate === null; + const isFalsy = dataToValidate === false || dataToValidate === "false" || dataToValidate === undefined || dataToValidate === null; return { - ok: !isFalsey, - message: !isFalsey ? "Success" : "Extracted value is falsey", + ok: !isFalsy, + message: !isFalsy ? "Success" : "Extracted value is falsy", extracted: dataToValidate, }; } From 465cea21bcc82a625908271ff4802ad26ac4993d Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:29:44 -0700 Subject: [PATCH 07/20] use interface --- server/src/service/infrastructure/network/AdvancedMatcher.ts | 4 ++-- server/src/service/infrastructure/network/HttpProvider.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/service/infrastructure/network/AdvancedMatcher.ts b/server/src/service/infrastructure/network/AdvancedMatcher.ts index f867770f3..d6350ef63 100644 --- a/server/src/service/infrastructure/network/AdvancedMatcher.ts +++ b/server/src/service/infrastructure/network/AdvancedMatcher.ts @@ -2,11 +2,11 @@ import { Monitor } from "@/types/monitor.js"; import jmespath from "jmespath"; type JmesPath = typeof jmespath; -export interface IADvancedMatcher { +export interface IAdvancedMatcher { validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined }; } -export class AdvancedMatcher { +export class AdvancedMatcher implements IAdvancedMatcher { constructor(private jmespath: JmesPath) {} private compare(actual: unknown, expected: string, method?: string): boolean { diff --git a/server/src/service/infrastructure/network/HttpProvider.ts b/server/src/service/infrastructure/network/HttpProvider.ts index a947727fd..bbc0934f8 100644 --- a/server/src/service/infrastructure/network/HttpProvider.ts +++ b/server/src/service/infrastructure/network/HttpProvider.ts @@ -1,5 +1,5 @@ import { type Got, HTTPError, RequestError } from "got"; -import { AdvancedMatcher } from "@/service/infrastructure/network/AdvancedMatcher.js"; +import { IAdvancedMatcher } from "@/service/infrastructure/network/AdvancedMatcher.js"; import { IStatusProvider } from "@/service/infrastructure/network/IStatusProvider.js"; import { HttpStatusPayload } from "@/types/network.js"; import { MonitorStatusResponse } from "@/types/network.js"; @@ -13,7 +13,7 @@ export class HttpProvider implements IStatusProvider { constructor( private got: Got, - private advancedMatcher: AdvancedMatcher + private advancedMatcher: IAdvancedMatcher ) { const cacheable = new CacheableLookup({ maxTtl: 300, errorTtl: 30 }); this.got = got.extend({ From 928ab7551ea530bfb701554a4420b5ad49fff981 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:33:40 -0700 Subject: [PATCH 08/20] fixes --- server/src/controllers/maintenanceWindowController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/controllers/maintenanceWindowController.ts b/server/src/controllers/maintenanceWindowController.ts index edc236fa1..300cb0b1b 100644 --- a/server/src/controllers/maintenanceWindowController.ts +++ b/server/src/controllers/maintenanceWindowController.ts @@ -24,7 +24,7 @@ class MaintenanceWindowController { const monitorIDs = validatedBody.monitors; const name = validatedBody.name; - const active = validatedBody.active ? validatedBody.active : true; + const active = validatedBody.active ?? true; const duration = validatedBody.duration; const durationUnit = validatedBody.durationUnit; const repeat = validatedBody.repeat; From 8322adbb2645ea49315042cd798393cf5bde9619 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:39:19 -0700 Subject: [PATCH 09/20] statusPageController interface --- server/src/controllers/statusPageController.ts | 13 +++++++++++-- server/src/routes/statusPageRoute.ts | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/src/controllers/statusPageController.ts b/server/src/controllers/statusPageController.ts index 8593cd53f..0c73b6e3b 100644 --- a/server/src/controllers/statusPageController.ts +++ b/server/src/controllers/statusPageController.ts @@ -15,7 +15,16 @@ import { NormalizeData } from "@/utils/dataUtils.js"; const SERVICE_NAME = "statusPageController"; -class StatusPageController { +export interface IStatusPageController { + readonly serviceName: string; + createStatusPage(req: Request, res: Response, next: NextFunction): Promise; + updateStatusPage(req: Request, res: Response, next: NextFunction): Promise; + getStatusPageByUrl(req: Request, res: Response, next: NextFunction): Promise; + getStatusPagesByTeamId(req: Request, res: Response, next: NextFunction): Promise; + deleteStatusPage(req: Request, res: Response, next: NextFunction): Promise; +} + +class StatusPageController implements IStatusPageController { static SERVICE_NAME = SERVICE_NAME; private statusPageService: IStatusPageService; private monitorsRepository: IMonitorsRepository; @@ -66,7 +75,7 @@ class StatusPageController { if (statusPage === null) { throw new AppError({ message: "Status page not found", status: 404 }); } - return res.status(200).json({ + res.status(200).json({ success: true, msg: "Status page updated successfully", data: statusPage, diff --git a/server/src/routes/statusPageRoute.ts b/server/src/routes/statusPageRoute.ts index a53aa04d9..871a67300 100755 --- a/server/src/routes/statusPageRoute.ts +++ b/server/src/routes/statusPageRoute.ts @@ -1,12 +1,13 @@ +import { IStatusPageController } from "@/controllers/statusPageController.js"; import { RequestHandler, Router } from "express"; import multer from "multer"; const upload = multer(); class StatusPageRoutes { private router: Router; - private statusPageController: any; + private statusPageController: IStatusPageController; - constructor(statusPageController: any, verifyJWT: RequestHandler, verifyStatusPageAccess: RequestHandler) { + constructor(statusPageController: IStatusPageController, verifyJWT: RequestHandler, verifyStatusPageAccess: RequestHandler) { this.router = Router(); this.statusPageController = statusPageController; this.initRoutes(verifyJWT, verifyStatusPageAccess); From 6fb7ad63f6dee7265eea754a6b44d35e7d4e1f93 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:42:40 -0700 Subject: [PATCH 10/20] settings --- server/src/controllers/authController.ts | 19 ++++++++++++++++++- server/src/controllers/settingsController.ts | 9 ++++++++- server/src/routes/settingsRoute.ts | 5 +++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/server/src/controllers/authController.ts b/server/src/controllers/authController.ts index 6eb49bbdd..20303b4eb 100755 --- a/server/src/controllers/authController.ts +++ b/server/src/controllers/authController.ts @@ -23,7 +23,24 @@ import { IUserService } from "@/service/index.js"; const SERVICE_NAME = "authController"; -class AuthController { +export interface IAuthController { + registerUser(req: Request, res: Response, next: NextFunction): Promise; + createUser(req: Request, res: Response, next: NextFunction): Promise; + loginUser(req: Request, res: Response, next: NextFunction): Promise; + editUser(req: Request, res: Response, next: NextFunction): Promise; + checkSuperadminExists(req: Request, res: Response, next: NextFunction): Promise; + requestRecovery(req: Request, res: Response, next: NextFunction): Promise; + validateRecovery(req: Request, res: Response, next: NextFunction): Promise; + resetPassword(req: Request, res: Response, next: NextFunction): Promise; + deleteUser(req: Request, res: Response, next: NextFunction): Promise; + deleteUserById(req: Request, res: Response, next: NextFunction): Promise; + getAllUsers(req: Request, res: Response, next: NextFunction): Promise; + getUserById(req: Request, res: Response, next: NextFunction): Promise; + editUserById(req: Request, res: Response, next: NextFunction): Promise; + editUserPasswordById(req: Request, res: Response, next: NextFunction): Promise; +} + +class AuthController implements IAuthController { static SERVICE_NAME = SERVICE_NAME; private userService: IUserService; diff --git a/server/src/controllers/settingsController.ts b/server/src/controllers/settingsController.ts index 0fd82a8ac..ca011889f 100644 --- a/server/src/controllers/settingsController.ts +++ b/server/src/controllers/settingsController.ts @@ -6,7 +6,14 @@ import { IEmailService, ISettingsService } from "@/service/index.js"; const SERVICE_NAME = "SettingsController"; -class SettingsController { +export interface ISettingsController { + serviceName: string; + getAppSettings(req: Request, res: Response, next: NextFunction): Promise; + updateAppSettings(req: Request, res: Response, next: NextFunction): Promise; + sendTestEmail(req: Request, res: Response, next: NextFunction): Promise; +} + +class SettingsController implements ISettingsController { static SERVICE_NAME = SERVICE_NAME; private settingsService: ISettingsService; private emailService: IEmailService; diff --git a/server/src/routes/settingsRoute.ts b/server/src/routes/settingsRoute.ts index c03c17524..aec2319c2 100755 --- a/server/src/routes/settingsRoute.ts +++ b/server/src/routes/settingsRoute.ts @@ -1,11 +1,12 @@ import { Router } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; +import { ISettingsController } from "@/controllers/settingsController.js"; class SettingsRoutes { private router: Router; - private settingsController: any; + private settingsController: ISettingsController; - constructor(settingsController: any) { + constructor(settingsController: ISettingsController) { this.router = Router(); this.settingsController = settingsController; this.initRoutes(); From 0495bef4692310bab63df21ea51fe010a16fafac Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:43:37 -0700 Subject: [PATCH 11/20] queue --- server/src/controllers/queueController.ts | 9 ++++++++- server/src/routes/queueRoute.ts | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/src/controllers/queueController.ts b/server/src/controllers/queueController.ts index 9ae2b494a..52762f42b 100755 --- a/server/src/controllers/queueController.ts +++ b/server/src/controllers/queueController.ts @@ -3,7 +3,14 @@ import { Request, Response, NextFunction } from "express"; const SERVICE_NAME = "JobQueueController"; -class JobQueueController { +export interface IJobQueueController { + getMetrics(req: Request, res: Response, next: NextFunction): Promise; + getJobs(req: Request, res: Response, next: NextFunction): Promise; + getAllMetrics(req: Request, res: Response, next: NextFunction): Promise; + flushQueue(req: Request, res: Response, next: NextFunction): Promise; +} + +class JobQueueController implements IJobQueueController { static SERVICE_NAME = SERVICE_NAME; private jobQueue: ISuperSimpleQueue; constructor(jobQueue: ISuperSimpleQueue) { diff --git a/server/src/routes/queueRoute.ts b/server/src/routes/queueRoute.ts index dd3b27999..d5d35147c 100755 --- a/server/src/routes/queueRoute.ts +++ b/server/src/routes/queueRoute.ts @@ -1,10 +1,11 @@ import { Router } from "express"; -import { isAllowed } from "../middleware/isAllowed.js"; +import { isAllowed } from "@/middleware/isAllowed.js"; +import { IJobQueueController } from "@/controllers/queueController.js"; class QueueRoutes { private router: Router; - private queueController: any; + private queueController: IJobQueueController; - constructor(queueController: any) { + constructor(queueController: IJobQueueController) { this.router = Router(); this.queueController = queueController; this.initRoutes(); From c7e449d18c21fe2785da2be1c91731c8e77313bc Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:45:04 -0700 Subject: [PATCH 12/20] notifications --- server/src/controllers/notificationController.ts | 11 ++++++++++- server/src/routes/notificationRoute.ts | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/src/controllers/notificationController.ts b/server/src/controllers/notificationController.ts index 9c39daee7..979e4afc9 100644 --- a/server/src/controllers/notificationController.ts +++ b/server/src/controllers/notificationController.ts @@ -15,7 +15,16 @@ import { requireTeamId, requireUserId } from "./controllerUtils.js"; const SERVICE_NAME = "NotificationController"; -class NotificationController { +export interface INotificationController { + testNotification: (req: Request, res: Response, next: NextFunction) => Promise; + createNotification: (req: Request, res: Response, next: NextFunction) => Promise; + getNotificationsByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; + deleteNotification: (req: Request, res: Response, next: NextFunction) => Promise; + getNotificationById: (req: Request, res: Response, next: NextFunction) => Promise; + editNotification: (req: Request, res: Response, next: NextFunction) => Promise; + testAllNotifications: (req: Request, res: Response, next: NextFunction) => Promise; +} +class NotificationController implements INotificationController { private notificationsService: INotificationsService; private monitorsRepository: IMonitorsRepository; constructor(notificationsService: INotificationsService, monitorsRepository: IMonitorsRepository) { diff --git a/server/src/routes/notificationRoute.ts b/server/src/routes/notificationRoute.ts index a1802d3b9..4ec6ce3b6 100755 --- a/server/src/routes/notificationRoute.ts +++ b/server/src/routes/notificationRoute.ts @@ -1,9 +1,10 @@ +import { INotificationController } from "@/controllers/notificationController.js"; import { Router } from "express"; class NotificationRoutes { private router: Router; - private notificationController: any; + private notificationController: INotificationController; - constructor(notificationController: any) { + constructor(notificationController: INotificationController) { this.router = Router(); this.notificationController = notificationController; this.initializeRoutes(); From d4a8023a76467981a353f69cbc79f190d2427a82 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:47:22 -0700 Subject: [PATCH 13/20] monitors --- server/src/controllers/monitorController.ts | 25 +++++++++++++++++++-- server/src/routes/monitorRoute.ts | 12 ++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/server/src/controllers/monitorController.ts b/server/src/controllers/monitorController.ts index 9a2b7b774..b3b03ed57 100644 --- a/server/src/controllers/monitorController.ts +++ b/server/src/controllers/monitorController.ts @@ -16,11 +16,32 @@ import { importMonitorsBodyValidation, } from "@/validation/monitorValidation.js"; import sslChecker from "ssl-checker"; -import { fetchMonitorCertificate, requireTeamId, requireUserId } from "./controllerUtils.js"; +import { fetchMonitorCertificate, requireTeamId, requireUserId } from "@/controllers/controllerUtils.js"; import { IMonitorService } from "@/service/index.js"; const SERVICE_NAME = "monitorController"; -class MonitorController { + +export interface IMonitorController { + getMonitorCertificate: (req: Request, res: Response, next: NextFunction) => Promise; + getUptimeDetailsById: (req: Request, res: Response, next: NextFunction) => Promise; + getHardwareDetailsById: (req: Request, res: Response, next: NextFunction) => Promise; + getPageSpeedDetailsById: (req: Request, res: Response, next: NextFunction) => Promise; + getGeoChecksByMonitorId: (req: Request, res: Response, next: NextFunction) => Promise; + getMonitorById: (req: Request, res: Response, next: NextFunction) => Promise; + createMonitor: (req: Request, res: Response, next: NextFunction) => Promise; + importMonitorsFromJSON: (req: Request, res: Response, next: NextFunction) => Promise; + deleteMonitor: (req: Request, res: Response, next: NextFunction) => Promise; + deleteAllMonitors: (req: Request, res: Response, next: NextFunction) => Promise; + editMonitor: (req: Request, res: Response, next: NextFunction) => Promise; + pauseMonitor: (req: Request, res: Response, next: NextFunction) => Promise; + addDemoMonitors: (req: Request, res: Response, next: NextFunction) => Promise; + getMonitorsByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; + getMonitorsWithChecksByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; + exportMonitorsToJSON: (req: Request, res: Response, next: NextFunction) => Promise; + getAllGames: (req: Request, res: Response, next: NextFunction) => Promise; + getGroupsByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; +} +class MonitorController implements IMonitorController { static SERVICE_NAME = SERVICE_NAME; private monitorService: IMonitorService; diff --git a/server/src/routes/monitorRoute.ts b/server/src/routes/monitorRoute.ts index 7cd87ee1e..2e994fd01 100755 --- a/server/src/routes/monitorRoute.ts +++ b/server/src/routes/monitorRoute.ts @@ -1,15 +1,11 @@ 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 -}); +import { IMonitorController } from "@/controllers/monitorController.js"; class MonitorRoutes { private router: Router; - private monitorController: any; - constructor(monitorController: any) { + private monitorController: IMonitorController; + constructor(monitorController: IMonitorController) { this.router = Router(); this.monitorController = monitorController; this.initRoutes(); @@ -38,7 +34,7 @@ class MonitorRoutes { // Util routes this.router.get("/certificate/:monitorId", (req, res, next) => { - this.monitorController.getMonitorCertificate(req, res, next, fetchMonitorCertificate); + this.monitorController.getMonitorCertificate(req, res, next); }); // General monitor CRUD routes From 332300dde4f3c627116da843ac48a774ba5f7521 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:48:58 -0700 Subject: [PATCH 14/20] log controller --- server/src/controllers/logController.ts | 4 ++++ server/src/controllers/maintenanceWindowController.ts | 10 +++++++++- server/src/routes/logRoutes.ts | 7 ++++--- server/src/routes/maintenanceWindowRoute.ts | 5 +++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/server/src/controllers/logController.ts b/server/src/controllers/logController.ts index e26bc2e5e..7d221c6c5 100644 --- a/server/src/controllers/logController.ts +++ b/server/src/controllers/logController.ts @@ -3,6 +3,10 @@ import { Request, Response, NextFunction } from "express"; const SERVICE_NAME = "LogController"; +export interface ILogController { + getLogs: (req: Request, res: Response, next: NextFunction) => Promise; +} + class LogController { static SERVICE_NAME = SERVICE_NAME; private logger: ILogger; diff --git a/server/src/controllers/maintenanceWindowController.ts b/server/src/controllers/maintenanceWindowController.ts index 300cb0b1b..441acfa80 100644 --- a/server/src/controllers/maintenanceWindowController.ts +++ b/server/src/controllers/maintenanceWindowController.ts @@ -11,7 +11,15 @@ import { import { requireTeamId } from "@/controllers/controllerUtils.js"; import { IMaintenanceWindowService } from "@/service/index.js"; -class MaintenanceWindowController { +export interface IMaintenanceWindowController { + createMaintenanceWindows: (req: Request, res: Response, next: NextFunction) => Promise; + getMaintenanceWindowById: (req: Request, res: Response, next: NextFunction) => Promise; + getMaintenanceWindowsByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; + getMaintenanceWindowsByMonitorId: (req: Request, res: Response, next: NextFunction) => Promise; + deleteMaintenanceWindow: (req: Request, res: Response, next: NextFunction) => Promise; + editMaintenanceWindow: (req: Request, res: Response, next: NextFunction) => Promise; +} +class MaintenanceWindowController implements IMaintenanceWindowController { private maintenanceWindowService: IMaintenanceWindowService; constructor(maintenanceWindowService: IMaintenanceWindowService) { this.maintenanceWindowService = maintenanceWindowService; diff --git a/server/src/routes/logRoutes.ts b/server/src/routes/logRoutes.ts index c35361fd0..ea03d690e 100755 --- a/server/src/routes/logRoutes.ts +++ b/server/src/routes/logRoutes.ts @@ -1,10 +1,11 @@ import { Router } from "express"; -import { isAllowed } from "../middleware/isAllowed.js"; +import { isAllowed } from "@/middleware/isAllowed.js"; +import { ILogController } from "@/controllers/logController.js"; class LogRoutes { private router: Router; - private logController: any; + private logController: ILogController; - constructor(logController: any) { + constructor(logController: ILogController) { this.router = Router(); this.logController = logController; this.initRoutes(); diff --git a/server/src/routes/maintenanceWindowRoute.ts b/server/src/routes/maintenanceWindowRoute.ts index 539f2413f..1c2c139c0 100755 --- a/server/src/routes/maintenanceWindowRoute.ts +++ b/server/src/routes/maintenanceWindowRoute.ts @@ -1,10 +1,11 @@ +import { IMaintenanceWindowController } from "@/controllers/maintenanceWindowController.js"; import { Router } from "express"; class MaintenanceWindowRoutes { private router: Router; - private mwController: any; + private mwController: IMaintenanceWindowController; - constructor(maintenanceWindowController: any) { + constructor(maintenanceWindowController: IMaintenanceWindowController) { this.router = Router(); this.mwController = maintenanceWindowController; this.initRoutes(); From 80f3168837312c6bc8a1f5a1537e666f0609fb54 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:50:47 -0700 Subject: [PATCH 15/20] invite, inident --- server/src/controllers/incidentController.ts | 9 ++++++++- server/src/controllers/inviteController.ts | 8 +++++++- server/src/routes/incidentRoute.ts | 5 +++-- server/src/routes/inviteRoute.ts | 5 +++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/server/src/controllers/incidentController.ts b/server/src/controllers/incidentController.ts index 4e6242184..f12327541 100644 --- a/server/src/controllers/incidentController.ts +++ b/server/src/controllers/incidentController.ts @@ -5,7 +5,14 @@ import { IIncidentService } from "@/service/index.js"; import { getIncidentsByTeamQueryValidation, getIncidentSummaryQueryValidation } from "@/validation/incidentValidation.js"; const SERVICE_NAME = "IncidentController"; -class IncidentController { + +export interface IIncidentController { + getIncidentsByTeam: (req: Request, res: Response, next: NextFunction) => Promise; + getIncidentSummary: (req: Request, res: Response, next: NextFunction) => Promise; + getIncidentById: (req: Request, res: Response, next: NextFunction) => Promise; + resolveIncidentManually: (req: Request, res: Response, next: NextFunction) => Promise; +} +class IncidentController implements IIncidentController { private incidentService: IIncidentService; constructor(incidentService: IIncidentService) { this.incidentService = incidentService; diff --git a/server/src/controllers/inviteController.ts b/server/src/controllers/inviteController.ts index 84f6c30ae..700a7bc6a 100755 --- a/server/src/controllers/inviteController.ts +++ b/server/src/controllers/inviteController.ts @@ -4,7 +4,13 @@ import { requireFirstName, requireTeamId, requireUserRoles } from "@/controllers import { IInviteService } from "@/service/index.js"; const SERVICE_NAME = "inviteController"; -class InviteController { +export interface IInviteController { + getInviteToken: (req: Request, res: Response, next: NextFunction) => Promise; + sendInviteEmail: (req: Request, res: Response, next: NextFunction) => Promise; + verifyInviteToken: (req: Request, res: Response, next: NextFunction) => Promise; +} + +class InviteController implements IInviteController { static SERVICE_NAME = SERVICE_NAME; private inviteService: IInviteService; constructor(inviteService: IInviteService) { diff --git a/server/src/routes/incidentRoute.ts b/server/src/routes/incidentRoute.ts index 83f1ff8f9..fdbb6f532 100644 --- a/server/src/routes/incidentRoute.ts +++ b/server/src/routes/incidentRoute.ts @@ -1,11 +1,12 @@ import { Router } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; +import { IIncidentController } from "@/controllers/incidentController.js"; class IncidentRoutes { private router: Router; - private incidentController: any; + private incidentController: IIncidentController; - constructor(incidentController: any) { + constructor(incidentController: IIncidentController) { this.router = Router(); this.incidentController = incidentController; this.initRoutes(); diff --git a/server/src/routes/inviteRoute.ts b/server/src/routes/inviteRoute.ts index b91f922df..4542bd21e 100755 --- a/server/src/routes/inviteRoute.ts +++ b/server/src/routes/inviteRoute.ts @@ -1,11 +1,12 @@ import { RequestHandler, Router } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; +import { IInviteController } from "@/controllers/inviteController.js"; class InviteRoutes { private router: Router; - private inviteController: any; + private inviteController: IInviteController; - constructor(inviteController: any, verifyJWT: RequestHandler) { + constructor(inviteController: IInviteController, verifyJWT: RequestHandler) { this.router = Router(); this.inviteController = inviteController; this.initRoutes(verifyJWT); From 05c293d689daecc9c9a97dfdfcf9f2537f4ebaeb Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:51:17 -0700 Subject: [PATCH 16/20] geo --- server/src/controllers/geoCheckController.ts | 5 ++++- server/src/routes/geoCheckRoutes.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/controllers/geoCheckController.ts b/server/src/controllers/geoCheckController.ts index aef0d7e7c..8ac130459 100644 --- a/server/src/controllers/geoCheckController.ts +++ b/server/src/controllers/geoCheckController.ts @@ -6,7 +6,10 @@ import { AppError } from "@/utils/AppError.js"; const SERVICE_NAME = "geoCheckController"; -class GeoCheckController { +export interface IGeoCheckController { + getGeoChecksByMonitor: (req: Request, res: Response, next: NextFunction) => Promise; +} +class GeoCheckController implements IGeoCheckController { static SERVICE_NAME = SERVICE_NAME; private geoChecksService: IGeoChecksService; diff --git a/server/src/routes/geoCheckRoutes.ts b/server/src/routes/geoCheckRoutes.ts index 4c34df56e..1fc48d7b3 100644 --- a/server/src/routes/geoCheckRoutes.ts +++ b/server/src/routes/geoCheckRoutes.ts @@ -1,10 +1,11 @@ +import { IGeoCheckController } from "@/controllers/geoCheckController.js"; import { Router } from "express"; class GeoCheckRoutes { private router: Router; - private geoCheckController: any; + private geoCheckController: IGeoCheckController; - constructor(geoCheckController: any) { + constructor(geoCheckController: IGeoCheckController) { this.router = Router(); this.geoCheckController = geoCheckController; this.initRoutes(); From 7456609e354bdaf354b2ede9d7c68fa58c39347e Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:51:54 -0700 Subject: [PATCH 17/20] diagnostic --- server/src/controllers/diagnosticController.ts | 7 ++++++- server/src/routes/diagnosticRoute.ts | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/src/controllers/diagnosticController.ts b/server/src/controllers/diagnosticController.ts index 19326d3b3..ffe7c6f5f 100755 --- a/server/src/controllers/diagnosticController.ts +++ b/server/src/controllers/diagnosticController.ts @@ -2,7 +2,12 @@ import { IDiagnosticService } from "@/service/index.js"; import { Request, Response, NextFunction } from "express"; const SERVICE_NAME = "diagnosticController"; -class DiagnosticController { + +export interface IDiagnosticController { + getSystemStats: (req: Request, res: Response, next: NextFunction) => Promise; +} + +class DiagnosticController implements IDiagnosticController { static SERVICE_NAME = SERVICE_NAME; private diagnosticService: IDiagnosticService; diff --git a/server/src/routes/diagnosticRoute.ts b/server/src/routes/diagnosticRoute.ts index b2cefe4aa..32b857e8d 100755 --- a/server/src/routes/diagnosticRoute.ts +++ b/server/src/routes/diagnosticRoute.ts @@ -1,11 +1,12 @@ import { RequestHandler, Router } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; +import { IDiagnosticController } from "@/controllers/diagnosticController.js"; class DiagnosticRoutes { private router: Router; - private diagnosticController: any; + private diagnosticController: IDiagnosticController; - constructor(diagnosticController: any, verifyJWT: RequestHandler) { + constructor(diagnosticController: IDiagnosticController, verifyJWT: RequestHandler) { this.router = Router(); this.diagnosticController = diagnosticController; this.initRoutes(verifyJWT); From 7144c20c5ba8388bb92e5b56a47a855eb4ef05d0 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:52:53 -0700 Subject: [PATCH 18/20] check,auth --- server/src/controllers/checkController.ts | 11 ++++++++++- server/src/routes/authRoute.ts | 5 +++-- server/src/routes/checkRoute.ts | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/server/src/controllers/checkController.ts b/server/src/controllers/checkController.ts index 879ceaffe..dfe64e80a 100755 --- a/server/src/controllers/checkController.ts +++ b/server/src/controllers/checkController.ts @@ -12,7 +12,16 @@ import { requireTeamId } from "@/controllers/controllerUtils.js"; const SERVICE_NAME = "checkController"; -class CheckController { +export interface ICheckController { + serviceName: string; + getChecksByMonitor: (req: Request, res: Response, next: NextFunction) => Promise; + getChecksByTeam: (req: Request, res: Response, next: NextFunction) => Promise; + getChecksSummaryByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; + deleteChecks: (req: Request, res: Response, next: NextFunction) => Promise; + deleteChecksByTeamId: (req: Request, res: Response, next: NextFunction) => Promise; +} + +class CheckController implements ICheckController { static SERVICE_NAME = SERVICE_NAME; private checkService: ICheckService; diff --git a/server/src/routes/authRoute.ts b/server/src/routes/authRoute.ts index 2e5fa1069..fd951c6b1 100755 --- a/server/src/routes/authRoute.ts +++ b/server/src/routes/authRoute.ts @@ -1,14 +1,15 @@ import { Router, RequestHandler } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; import multer from "multer"; +import { IAuthController } from "@/controllers/authController.js"; const upload = multer(); class AuthRoutes { private router: Router; - private authController: any; + private authController: IAuthController; - constructor(authController: any, verifyJWT: RequestHandler) { + constructor(authController: IAuthController, verifyJWT: RequestHandler) { this.router = Router(); this.authController = authController; this.initRoutes(verifyJWT); diff --git a/server/src/routes/checkRoute.ts b/server/src/routes/checkRoute.ts index 71a0cd5f3..712bae969 100755 --- a/server/src/routes/checkRoute.ts +++ b/server/src/routes/checkRoute.ts @@ -1,12 +1,13 @@ import { Router } from "express"; import { isAllowed } from "../middleware/isAllowed.js"; +import { ICheckController } from "@/controllers/checkController.js"; class CheckRoutes { private router: Router; - private checkController: any; + private checkController: ICheckController; - constructor(checkController: any) { + constructor(checkController: ICheckController) { this.router = Router(); this.checkController = checkController; this.initRoutes(); From 120c5cd4720239c1e317912bd275d4f0290b08bc Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 12:16:23 -0700 Subject: [PATCH 19/20] repo lint errors --- .../geo-checks/MongoGeoChecksRepository.ts | 70 +++++++++---------- .../incidents/MongoIncidentRepository.ts | 4 +- .../MongoMaintenanceWindowsRepository.ts | 8 +-- .../monitors/MongoMonitorsRepository.ts | 20 +++--- .../MongoStatusPagesRepository.ts | 6 +- .../users/MongoUsersRepository.ts | 2 +- 6 files changed, 52 insertions(+), 58 deletions(-) diff --git a/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts b/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts index e1db5ab1d..0adcf7c9f 100644 --- a/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts +++ b/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts @@ -1,8 +1,8 @@ import { IGeoChecksRepository } from "./IGeoChecksRepository.js"; import type { GeoCheck, GeoCheckMetadata, GeoCheckResult, GroupedGeoCheck, GeoContinent, FlatGeoCheck } from "@/types/geoCheck.js"; import type { FlatGeoChecksQueryResult } from "./IGeoChecksRepository.js"; -import { GeoCheckModel, type GeoCheckDocument } from "@/db/models/index.js"; -import mongoose from "mongoose"; +import { GeoCheckMetadataDocument, GeoCheckModel, type GeoCheckDocument } from "@/db/models/index.js"; +import mongoose, { PipelineStage } from "mongoose"; import { getDateForRange } from "@/utils/dataUtils.js"; import { ILogger } from "@/utils/logger.js"; @@ -31,13 +31,13 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { return value instanceof Date ? value.toISOString() : new Date(value).toISOString(); }; - const mapMetadata = (metadata: any): GeoCheckMetadata => ({ + const mapMetadata = (metadata: GeoCheckMetadataDocument): GeoCheckMetadata => ({ monitorId: toStringId(metadata.monitorId), teamId: toStringId(metadata.teamId), type: metadata.type, }); - const mapResults = (results: any[]): GeoCheckResult[] => { + const mapResults = (results: GeoCheckResult[]): GeoCheckResult[] => { if (!results || !Array.isArray(results)) { return []; } @@ -89,12 +89,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { })) ); return docs.map((doc) => this.toEntity(doc)); - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Failed to createGeoChecks: ${error.message}`, + message: error instanceof Error ? `Failed to createGeoChecks: ${error.message}` : "Failed to createGeoChecks", service: SERVICE_NAME, method: "createGeoChecks", - stack: error.stack, + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -109,7 +109,7 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { continents?: GeoContinent[] ): Promise => { try { - const matchStage: Record = { + const matchStage: Record = { "metadata.monitorId": new mongoose.Types.ObjectId(monitorId), ...(getDateForRange(dateRange) && { createdAt: { @@ -125,22 +125,8 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { skip = page * rowsPerPage; } - if (continents && continents.length > 0) { - const pipeline: any[] = [ - { $match: matchStage }, - { $unwind: "$results" }, - { - $match: { - "results.location.continent": { $in: continents }, - }, - }, - ]; - } else { - const pipeline: any[] = [{ $match: matchStage }, { $unwind: "$results" }]; - } - // Common pipeline stages for both paths - const pipeline: any[] = [ + const pipeline: PipelineStage[] = [ { $match: matchStage }, { $unwind: "$results" }, // Filter by continent if specified @@ -174,7 +160,7 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { ]; // Count pipeline - const countPipeline: any[] = [ + const countPipeline: PipelineStage[] = [ { $match: matchStage }, { $unwind: "$results" }, ...(continents && continents.length > 0 @@ -206,12 +192,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { })); return { geoChecksCount, geoChecks }; - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error finding geo checks by monitor ID: ${error.message}`, + message: error instanceof Error ? `Error finding geo checks by monitor ID: ${error.message}` : "Error finding geo checks by monitor ID", service: SERVICE_NAME, method: "findByMonitorId", - stack: error.stack, + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -227,11 +213,15 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { }, }).sort({ createdAt: -1 }); return docs.map(this.toEntity); - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error finding geo checks by monitor ID and date range: ${error.message}`, + message: + error instanceof Error + ? `Error finding geo checks by monitor ID and date range: ${error.message}` + : "Error finding geo checks by monitor ID and date range", service: SERVICE_NAME, method: "findByMonitorIdAndDateRange", + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -245,7 +235,7 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { continents?: GeoContinent[] ): Promise => { try { - const pipeline: any[] = [ + const pipeline: PipelineStage[] = [ // Match geo checks for this monitor in date range { $match: { @@ -325,11 +315,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { const results = await GeoCheckModel.aggregate(pipeline); return results as GroupedGeoCheck[]; - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error finding grouped geo checks: ${error.message}`, + message: error instanceof Error ? `Error finding grouped geo checks: ${error.message}` : "Error finding grouped geo checks", service: SERVICE_NAME, method: "findGroupedByMonitorIdAndDateRange", + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -341,11 +332,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { "metadata.monitorId": new mongoose.Types.ObjectId(monitorId), }); return result.deletedCount || 0; - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error deleting geo checks by monitor ID: ${error.message}`, + message: error instanceof Error ? `Error deleting geo checks by monitor ID: ${error.message}` : "Error deleting geo checks by monitor ID", service: SERVICE_NAME, method: "deleteByMonitorId", + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -357,11 +349,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { "metadata.teamId": new mongoose.Types.ObjectId(teamId), }); return result.deletedCount || 0; - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error deleting geo checks by team ID: ${error.message}`, + message: error instanceof Error ? `Error deleting geo checks by team ID: ${error.message}` : "Error deleting geo checks by team ID", service: SERVICE_NAME, method: "deleteByTeamId", + stack: error instanceof Error ? error.stack : undefined, }); throw error; } @@ -372,11 +365,12 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { const objectIds = monitorIds.map((id) => new mongoose.Types.ObjectId(id)); const result = await GeoCheckModel.deleteMany({ "metadata.monitorId": { $nin: objectIds } }); return result.deletedCount || 0; - } catch (error: any) { + } catch (error: unknown) { this.logger.error({ - message: `Error deleting orphaned geo checks: ${error.message}`, + message: error instanceof Error ? `Error deleting orphaned geo checks: ${error.message}` : "Error deleting orphaned geo checks", service: SERVICE_NAME, method: "deleteByMonitorIdsNotIn", + stack: error instanceof Error ? error.stack : undefined, }); throw error; } diff --git a/server/src/repositories/incidents/MongoIncidentRepository.ts b/server/src/repositories/incidents/MongoIncidentRepository.ts index 93ecac248..096ba3d37 100644 --- a/server/src/repositories/incidents/MongoIncidentRepository.ts +++ b/server/src/repositories/incidents/MongoIncidentRepository.ts @@ -32,8 +32,8 @@ class MongoIncidentRepository implements IIncidentsRepository { status?: boolean; monitorId?: string; resolutionType?: string; - }): Record { - const matchStage: Record = { + }): Record { + const matchStage: Record = { teamId: new mongoose.Types.ObjectId(teamId), ...(status !== undefined && { status }), ...(monitorId && { monitorId: new mongoose.Types.ObjectId(monitorId) }), diff --git a/server/src/repositories/maintenance-windows/MongoMaintenanceWindowsRepository.ts b/server/src/repositories/maintenance-windows/MongoMaintenanceWindowsRepository.ts index d924613ee..ad96328c5 100644 --- a/server/src/repositories/maintenance-windows/MongoMaintenanceWindowsRepository.ts +++ b/server/src/repositories/maintenance-windows/MongoMaintenanceWindowsRepository.ts @@ -1,7 +1,7 @@ import type { MaintenanceWindow } from "@/types/index.js"; import { type MaintenanceWindowDocument, MaintenanceWindowModel } from "@/db/models/index.js"; import { IMaintenanceWindowsRepository } from "./IMaintenanceWindowsRepository.js"; -import mongoose from "mongoose"; +import mongoose, { SortOrder } from "mongoose"; import { AppError } from "@/utils/AppError.js"; class MongoMaintenanceWindowsRepository implements IMaintenanceWindowsRepository { @@ -81,7 +81,7 @@ class MongoMaintenanceWindowsRepository implements IMaintenanceWindowsRepository order?: string, active?: boolean ): Promise => { - const maintenanceQuery: Record = { teamId }; + const maintenanceQuery: Record = { teamId }; if (active !== undefined) maintenanceQuery.active = active; @@ -92,7 +92,7 @@ class MongoMaintenanceWindowsRepository implements IMaintenanceWindowsRepository } // Sorting - const sort: Record = {}; + const sort: Record = {}; if (field !== undefined && order !== undefined) { sort[field] = order === "asc" ? 1 : -1; } @@ -127,7 +127,7 @@ class MongoMaintenanceWindowsRepository implements IMaintenanceWindowsRepository return this.toEntity(deleted); }; countByTeamId = async (teamId: string, active?: boolean) => { - const maintenanceQuery: Record = { teamId }; + const maintenanceQuery: Record = { teamId }; if (active !== undefined) maintenanceQuery.active = active; diff --git a/server/src/repositories/monitors/MongoMonitorsRepository.ts b/server/src/repositories/monitors/MongoMonitorsRepository.ts index a3b40f459..3269dbe3f 100644 --- a/server/src/repositories/monitors/MongoMonitorsRepository.ts +++ b/server/src/repositories/monitors/MongoMonitorsRepository.ts @@ -1,8 +1,9 @@ import { MonitorModel } from "@/db/models/index.js"; import type { MonitorDocument, CheckSnapshotDocument } from "@/db/models/index.js"; -import type { Monitor, MonitorsSummary, CheckSnapshot, Check } from "@/types/index.js"; +import type { Monitor, MonitorsSummary, CheckSnapshot } from "@/types/index.js"; import mongoose, { type FilterQuery, type PipelineStage } from "mongoose"; import type { IMonitorsRepository, TeamQueryConfig, SummaryConfig } from "./IMonitorsRepository.js"; +import { MongoBulkWriteError } from "mongodb"; import { AppError } from "@/utils/AppError.js"; class MongoMonitorsRepository implements IMonitorsRepository { @@ -20,12 +21,9 @@ class MongoMonitorsRepository implements IMonitorsRepository { try { const inserted = await MonitorModel.insertMany(payload, { ordered: false }); return this.mapDocuments(inserted); - } catch (error: any) { - if (error.name === "MongoBulkWriteError" || error.name === "BulkWriteError") { - const insertedDocs = error.insertedDocs || []; - if (insertedDocs.length > 0) { - return this.mapDocuments(insertedDocs); - } + } catch (error: unknown) { + if (error instanceof MongoBulkWriteError && "insertedDocs" in error && Array.isArray(error.insertedDocs) && error.insertedDocs.length > 0) { + return this.mapDocuments(error.insertedDocs); } throw error; } @@ -46,7 +44,7 @@ class MongoMonitorsRepository implements IMonitorsRepository { }; findByTeamId = async (teamId: string, config: TeamQueryConfig): Promise => { - const { page = 0, rowsPerPage = 0, filter, field = "createdAt", order = "desc", type, limit } = config ?? {}; + const { page = 0, rowsPerPage = 0, filter, field = "createdAt", order = "desc", type } = config ?? {}; const query: Record = { teamId: new mongoose.Types.ObjectId(teamId), @@ -354,7 +352,7 @@ class MongoMonitorsRepository implements IMonitorsRepository { gameId: doc.gameId ?? undefined, grpcServiceName: doc.grpcServiceName ?? undefined, group: doc.group ?? null, - recentChecks: (doc.recentChecks ?? []).map((check: any) => this.toCheckSnapshot(check)), + recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)), geoCheckEnabled: doc.geoCheckEnabled ?? false, geoCheckLocations: doc.geoCheckLocations ?? [], geoCheckInterval: doc.geoCheckInterval ?? 300000, @@ -363,7 +361,7 @@ class MongoMonitorsRepository implements IMonitorsRepository { }; }; - private toEntityWithChecks = (doc: any): Monitor => { + private toEntityWithChecks = (doc: MonitorDocument): Monitor => { const toStringId = (value: unknown): string => { if (value instanceof mongoose.Types.ObjectId) { return value.toString(); @@ -413,7 +411,7 @@ class MongoMonitorsRepository implements IMonitorsRepository { gameId: doc.gameId ?? undefined, grpcServiceName: doc.grpcServiceName ?? undefined, group: doc.group ?? null, - recentChecks: (doc.recentChecks ?? []).map((check: any) => this.toCheckSnapshot(check)), + recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)), geoCheckEnabled: doc.geoCheckEnabled ?? false, geoCheckLocations: doc.geoCheckLocations ?? [], geoCheckInterval: doc.geoCheckInterval ?? 300000, diff --git a/server/src/repositories/status-pages/MongoStatusPagesRepository.ts b/server/src/repositories/status-pages/MongoStatusPagesRepository.ts index eb2d92729..d8e942271 100644 --- a/server/src/repositories/status-pages/MongoStatusPagesRepository.ts +++ b/server/src/repositories/status-pages/MongoStatusPagesRepository.ts @@ -72,7 +72,8 @@ class MongoStatusPagesRepository implements IStatusPagesRepository { }; create = async (userId: string, teamId: string, image: Express.Multer.File | undefined, data: Partial): Promise => { - const { logo: _logo, ...restData } = data; + const { logo, ...restData } = data; + void logo; const statusPage = new StatusPageModel({ ...restData, userId, @@ -110,7 +111,8 @@ class MongoStatusPagesRepository implements IStatusPagesRepository { image: Express.Multer.File | undefined, patch: Partial & { removeLogo?: string } ): Promise => { - const { logo: _logo, removeLogo, ...restPatch } = patch; + const { logo, removeLogo, ...restPatch } = patch; + void logo; const updateData: StatusPageUpdateData = { ...restPatch }; if (image) { updateData.logo = { diff --git a/server/src/repositories/users/MongoUsersRepository.ts b/server/src/repositories/users/MongoUsersRepository.ts index fde134a33..a8525f2c8 100644 --- a/server/src/repositories/users/MongoUsersRepository.ts +++ b/server/src/repositories/users/MongoUsersRepository.ts @@ -117,7 +117,7 @@ class MongoUsersRepository implements IUsersRepository { delete candidateUser.deleteProfileImage; - const updateQuery: Record = { $set: candidateUser }; + const updateQuery: Record = { $set: candidateUser }; if (unsetFields) { updateQuery.$unset = unsetFields; } From 1a504a3cd95221d61afeb9a4288babca048e92f1 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 12:22:22 -0700 Subject: [PATCH 20/20] fix migraiton lint errors --- .../src/db/migration/0002_convertChecksToTimeSeries.ts | 10 ++++++---- .../db/migration/0003_cleanupDuplicateMonitorStats.ts | 4 ++-- .../db/migration/0004_fixInfrastructureThresholds.ts | 3 ++- server/src/db/migration/index.ts | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/server/src/db/migration/0002_convertChecksToTimeSeries.ts b/server/src/db/migration/0002_convertChecksToTimeSeries.ts index 01ed82def..cc2d20b23 100644 --- a/server/src/db/migration/0002_convertChecksToTimeSeries.ts +++ b/server/src/db/migration/0002_convertChecksToTimeSeries.ts @@ -1,4 +1,5 @@ import mongoose from "mongoose"; +import type { Document, AnyBulkWriteOperation } from "mongodb"; const CHECKS_COLLECTION = "checks"; const BACKUP_COLLECTION = "checks_backup"; @@ -85,7 +86,7 @@ const createTimeSeriesCollection = async (backedUp: boolean) => { } }; -const validateDocument = (doc: any): boolean => { +const validateDocument = (doc: Document): boolean => { if (!doc.createdAt) { return false; } @@ -95,7 +96,7 @@ const validateDocument = (doc: any): boolean => { return true; }; -const storeFailedDocument = async (doc: any, reason: string) => { +const storeFailedDocument = async (doc: Document, reason: string) => { const db = getDb(); await db.collection(FAILED_DOCS_COLLECTION).insertOne({ originalDoc: doc, @@ -124,8 +125,8 @@ const migrateBackupData = async (backedUp: boolean): Promise => stats.totalSource = await source.countDocuments(); const cursor = source.find().addCursorFlag("noCursorTimeout", true); - const operations: any[] = []; - const invalidDocs: any[] = []; + const operations: AnyBulkWriteOperation[] = []; + const invalidDocs: Document[] = []; while (await cursor.hasNext()) { const doc = await cursor.next(); @@ -139,6 +140,7 @@ const migrateBackupData = async (backedUp: boolean): Promise => } const { _id, monitorId, teamId, type, ...rest } = doc; + void _id; const metadata = { monitorId, teamId, type }; operations.push({ insertOne: { document: { ...rest, metadata } } }); diff --git a/server/src/db/migration/0003_cleanupDuplicateMonitorStats.ts b/server/src/db/migration/0003_cleanupDuplicateMonitorStats.ts index 1371ab798..c4dff2fc0 100644 --- a/server/src/db/migration/0003_cleanupDuplicateMonitorStats.ts +++ b/server/src/db/migration/0003_cleanupDuplicateMonitorStats.ts @@ -42,10 +42,10 @@ export async function cleanupDuplicateMonitorStats(): Promise { const monitorId = duplicate._id; const { ids, updatedAts } = duplicate; - type DocPair = { id: any; updatedAt: Date }; + type DocPair = { id: string; updatedAt: Date }; // Create array of {id, updatedAt} pairs and sort by updatedAt descending - const docs: DocPair[] = ids.map((id: any, index: number) => ({ + const docs: DocPair[] = ids.map((id: string, index: number) => ({ id, updatedAt: updatedAts[index], })); diff --git a/server/src/db/migration/0004_fixInfrastructureThresholds.ts b/server/src/db/migration/0004_fixInfrastructureThresholds.ts index 6d369f311..bf6458565 100644 --- a/server/src/db/migration/0004_fixInfrastructureThresholds.ts +++ b/server/src/db/migration/0004_fixInfrastructureThresholds.ts @@ -37,7 +37,8 @@ export async function fixInfrastructureThresholds(): Promise { const update: Record = {}; for (const field of thresholdFields) { - if ((monitor as any)[field] === 0 || (monitor as any)[field] === 5) { + const value = monitor.get(field); + if (value === 0 || value === 5) { update[field] = 100; } } diff --git a/server/src/db/migration/index.ts b/server/src/db/migration/index.ts index 61f16ed4d..f1a672af9 100644 --- a/server/src/db/migration/index.ts +++ b/server/src/db/migration/index.ts @@ -4,6 +4,7 @@ import { cleanupDuplicateMonitorStats } from "./0003_cleanupDuplicateMonitorStat import { fixInfrastructureThresholds } from "./0004_fixInfrastructureThresholds.js"; import MigrationModel from "../models/Migration.js"; import { migrateStatusPageTypeToArray } from "./0005_migrateStatusPageTypeToArray.js"; +import type { ILogger } from "@/utils/logger.js"; type MigrationEntry = { name: string; @@ -18,7 +19,7 @@ const migrations: MigrationEntry[] = [ { name: "0005_migrateStatusPageTypeToArray", execute: migrateStatusPageTypeToArray }, ]; -const runMigrations = async (logger?: { info: Function; error: Function }) => { +const runMigrations = async (logger?: ILogger) => { try { logger?.info({ message: "Running migrations", service: "Migrations" }); for (const migration of migrations) { @@ -45,7 +46,7 @@ const runMigrations = async (logger?: { info: Function; error: Function }) => { logger?.info({ message: "Migrations completed", service: "Migrations" }); } catch (error) { const err = error as Error; - logger?.error({ message: "Migration failed", service: "Migrations", details: err?.message, stack: err?.stack }); + logger?.error({ message: "Migration failed", service: "Migrations", details: { error: err?.message }, stack: err?.stack }); throw error; } };