Merge pull request #3404 from bluewave-labs/fix/controller-utils-types

fix: controller utils types
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-03-11 10:51:11 -07:00
commit 01401d56b8
2 files changed
+29 -4

No files matched your search

+5 -4
View File
@@ -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";
import sslChecker, { SSLDetails } from "ssl-checker";
type SSLCheckerType = typeof sslChecker;
const fetchMonitorCertificate = async (sslChecker: any, monitor: any): Promise<any> => {
const fetchMonitorCertificate = async (checker: SSLCheckerType, monitor: Monitor): Promise<SSLDetails> => {
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");
}
+24
View File
@@ -0,0 +1,24 @@
declare module "ssl-checker" {
import { Agent } from "https";
export interface SSLDetails {
daysRemaining: number;
valid: boolean;
validFrom: string;
validTo: string;
validFor: string[];
}
export interface SSLOptions {
method?: "GET" | "HEAD";
port?: number;
agent?: Agent;
rejectUnauthorized?: boolean;
validateSubjectAltName?: boolean;
}
function sslChecker(hostname: string, options?: SSLOptions): Promise<SSLDetails>;
// Change 'export default' to 'export =' to allow it to be callable
export = sslChecker;
}