refactor: extract isStatusUp utility to decouple from got's response.ok and modified utils test accordingly
This commit is contained in:
1 parent
372fc9869b
commit
5628c202f7
5 files changed
+50
-8
No files matched your search
@@ -3,6 +3,7 @@ import { supportsGeoCheck, type HttpStatusCode } from "@/types/monitor.js";
|
||||
import { MonitorType } from "@/types/index.js";
|
||||
import type { ILogger } from "@/utils/logger.js";
|
||||
import got from "got";
|
||||
import { isStatusUp } from "@/service/infrastructure/network/utils.js";
|
||||
|
||||
const SERVICE_NAME = "GlobalPingService";
|
||||
const GLOBAL_PING_API_BASE = "https://api.globalping.io/v1";
|
||||
@@ -209,8 +210,7 @@ export class GlobalPingService implements IGlobalPingService {
|
||||
|
||||
successfulResults.push({
|
||||
location,
|
||||
status:
|
||||
customUpCodes.includes(probeResult.result.statusCode) || (probeResult.result.statusCode >= 200 && probeResult.result.statusCode < 300),
|
||||
status: isStatusUp(probeResult.result.statusCode, customUpCodes),
|
||||
statusCode: probeResult.result.statusCode,
|
||||
timings,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user