From 24b9b649791c45f085db82aa8e316183eb7c9a69 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 6 Mar 2026 09:35:07 -0800 Subject: [PATCH] manually build response --- .../infrastructure/network/PingProvider.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/server/src/service/infrastructure/network/PingProvider.ts b/server/src/service/infrastructure/network/PingProvider.ts index 2749584f5..03181b078 100644 --- a/server/src/service/infrastructure/network/PingProvider.ts +++ b/server/src/service/infrastructure/network/PingProvider.ts @@ -4,7 +4,7 @@ import { MonitorType, Monitor } from "@/types/monitor.js"; import { MonitorStatusResponse } from "@/types/network.js"; import { AppError } from "@/utils/AppError.js"; import ping from "ping"; -import { buildStatusResponse, timeRequest } from "@/service/infrastructure/network/utils.js"; +import { timeRequest } from "@/service/infrastructure/network/utils.js"; const SERVICE_NAME = "PingProvider"; type Ping = typeof ping; @@ -33,7 +33,7 @@ export class PingProvider implements IStatusProvider { const sanitizedHost = this.sanitizeHost(monitor.url); const { response, error } = await timeRequest(() => this.ping.promise.probe(sanitizedHost)); - const safeTime = typeof response?.time === "number" ? response.time : parseFloat(String(response?.time)) || 0; + if (error) { throw error; } @@ -42,16 +42,19 @@ export class PingProvider implements IStatusProvider { throw new Error(`No response from ping for host: ${sanitizedHost}`); } - return buildStatusResponse({ - monitor, + const responseTime = + typeof response.time === "number" ? response.time : parseFloat(String(response.time)) || 0; + + return { + monitorId: monitor.id, + teamId: monitor.teamId, + type: monitor.type, + status: response.alive ?? false, + code: response.alive ? 200 : 5000, + message: response.alive ? "Success" : "Ping failed", + responseTime, payload: response, - overrides: { - status: response.alive ?? false, - code: 200, - message: "Success", - responseTime: safeTime, - }, - }); + }; } catch (err: unknown) { const message = err instanceof Error ? err.message : String(err); throw new AppError({