This commit is contained in:
Alex Holliday committed 2026-01-15 23:45:40 +00:00
1 parent ed80837810
commit 0f764ca084
12 files changed
+431 -116

No files matched your search

+3 -24
View File
@@ -1,4 +1,6 @@
import type { MonitorType } from "@/types/index.js";
import type { Response } from "got";
export type GotTimings = Response["timings"];
export interface CheckMetadata {
monitorId: string;
@@ -6,29 +8,6 @@ export interface CheckMetadata {
type: MonitorType;
}
export interface CheckTimingPhases {
wait: number;
dns: number;
tcp: number;
tls: number;
request: number;
firstByte: number;
download: number;
total: number;
}
export interface CheckTimings {
start: number;
socket: number;
lookup: number;
connect: number;
secureConnect: number;
upload: number;
response: number;
end: number;
phases: CheckTimingPhases;
}
export interface CheckCpuInfo {
physical_core: number;
logical_core: number;
@@ -107,7 +86,7 @@ export interface Check {
metadata: CheckMetadata;
status: boolean;
responseTime: number;
timings: CheckTimings;
timings: GotTimings;
statusCode: number;
message: string;
ack: boolean;
+1
View File
@@ -2,3 +2,4 @@ export * from "@/types/check.js";
export * from "@/types/monitor.js";
export * from "@/types/monitorStats.js";
export * from "@/types/statusPage.js";
export * from "@/types/network.js";
+112
View File
@@ -0,0 +1,112 @@
import type {
CheckCaptureInfo,
CheckCpuInfo,
CheckDiskInfo,
CheckErrorInfo,
CheckHostInfo,
CheckMemoryInfo,
CheckNetworkInterfaceInfo,
GotTimings,
ILighthouseAudit,
Monitor,
MonitorMatchMethod,
MonitorType,
} from "@/types/index.js";
export interface MonitorStatusResponse<T = unknown> {
monitorId: string;
teamId: string;
type: MonitorType | "unknown";
status: boolean;
code: number;
message: string;
responseTime?: number;
payload?: T | null;
timings?: GotTimings;
first_byte_took?: number;
body_read_took?: number;
dns_took?: number;
conn_took?: number;
connect_took?: number;
tls_took?: number;
jsonPath?: string;
matchMethod?: MonitorMatchMethod;
expectedValue?: string;
extracted?: unknown;
}
export interface PingStatusPayload {
host: string;
numeric_host?: string;
alive: boolean;
time: number;
times?: number[];
output?: string;
min?: string;
max?: string;
avg?: string;
stddev?: string;
packetLoss?: string;
}
export type HttpStatusPayload = unknown;
export interface PageSpeedCategoryScore {
score?: number | null;
}
export interface PageSpeedStatusPayload {
lighthouseResult?: {
categories?: {
accessibility?: PageSpeedCategoryScore;
"best-practices"?: PageSpeedCategoryScore;
performance?: PageSpeedCategoryScore;
seo?: PageSpeedCategoryScore;
[key: string]: PageSpeedCategoryScore | undefined;
};
audits?: Record<string, ILighthouseAudit | undefined>;
};
[key: string]: unknown;
}
export interface HardwareStatusMetrics {
cpu?: CheckCpuInfo;
memory?: CheckMemoryInfo;
disk?: CheckDiskInfo[];
host?: CheckHostInfo;
net?: CheckNetworkInterfaceInfo[];
}
export interface HardwareStatusPayload {
data?: HardwareStatusMetrics;
errors?: CheckErrorInfo[] | { errors?: CheckErrorInfo[] };
capture?: CheckCaptureInfo;
[key: string]: unknown;
}
export type DockerStatusPayload = Record<string, unknown>;
export interface PortStatusPayload {
success: boolean;
}
export type GameStatusPayload = Record<string, unknown>;
export interface MonitorPayloadMap {
ping: PingStatusPayload;
http: HttpStatusPayload;
pagespeed: PageSpeedStatusPayload;
hardware: HardwareStatusPayload;
docker: DockerStatusPayload;
port: PortStatusPayload;
game: GameStatusPayload;
default: unknown;
}
export type StatusChangeResult = {
monitor: Monitor;
statusChanged: boolean;
prevStatus: boolean | undefined;
code: number;
timestamp: number;
};