feat(web): SPA skeleton embedded in the binary (#60)
This commit was merged in pull request #60.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Hand-written mirror of arr-api's /api/health schema. `just gen-client`
|
||||
// output (src/api/) is uncommitted, so CI's tsc cannot see it — this one
|
||||
// endpoint stays hand-typed until the generated client is wired in.
|
||||
|
||||
export type CheckStatus = "ok" | "unreachable" | "unconfigured";
|
||||
|
||||
export interface Check {
|
||||
status: CheckStatus;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export interface HealthReport {
|
||||
status: "ok" | "degraded";
|
||||
version: string;
|
||||
prowlarr: Check;
|
||||
transmission: Check;
|
||||
tmdb: Check;
|
||||
}
|
||||
|
||||
export type Probe =
|
||||
| { kind: "report"; report: HealthReport; roundtripMs: number }
|
||||
| { kind: "unreachable"; detail: string };
|
||||
|
||||
/** One probe of the daemon. The endpoint always answers 200 with a verdict in
|
||||
* the body; anything else means the daemon itself is the outage. */
|
||||
export async function probeHealth(): Promise<Probe> {
|
||||
const started = performance.now();
|
||||
try {
|
||||
const response = await fetch("/api/health");
|
||||
if (!response.ok) {
|
||||
return { kind: "unreachable", detail: `http ${response.status}` };
|
||||
}
|
||||
const report = (await response.json()) as HealthReport;
|
||||
return {
|
||||
kind: "report",
|
||||
report,
|
||||
roundtripMs: Math.round(performance.now() - started),
|
||||
};
|
||||
} catch {
|
||||
return { kind: "unreachable", detail: "no response" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user