From 2884ab524d2f60350a9535f4d64fe0821812e534 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 10 Mar 2026 11:35:05 -0700 Subject: [PATCH] type fetchMonitorCertificate --- server/src/controllers/controllerUtils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/controllers/controllerUtils.ts b/server/src/controllers/controllerUtils.ts index e5c852591..173790cda 100755 --- a/server/src/controllers/controllerUtils.ts +++ b/server/src/controllers/controllerUtils.ts @@ -1,11 +1,12 @@ import { AppError } from "@/utils/AppError.js"; -import { type MonitorType, MonitorTypes, UserRole } from "@/types/index.js"; +import { Monitor, type MonitorType, MonitorTypes, UserRole } from "@/types/index.js"; +type SslCertificate = { valid: boolean; validFrom: string; validTo: string; daysRemaining: number; validFor?: string[] }; +type SslChecker = (host: string, options?: Record) => Promise; -const fetchMonitorCertificate = async (sslChecker: any, monitor: any): Promise => { +const fetchMonitorCertificate = async (checker: SslChecker, monitor: Monitor): Promise => { const monitorUrl = new URL(monitor.url); const hostname = monitorUrl.hostname; - const cert = await sslChecker(hostname); - // Throw an error if no cert or if cert.validTo is not present + const cert = await checker(hostname); if (cert?.validTo === null || cert?.validTo === undefined) { throw new Error("Certificate not found"); }