OPS-02: dev-server + next.js zentrale statusseite

This commit is contained in:
sysops
2026-08-28 08:21:27 +02:00
parent dff760e1ba
commit 81ebdd892b
7 changed files with 297 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
// Duenner Client des OPS-02-Backends (internal/statuspage) — keine eigene
// Aggregations-/Polling-Logik im Frontend.
export type ModuleStatus = {
name: string;
status: "up" | "down";
last_checked?: string;
};
export type HistoryEntry = {
status: "up" | "down";
changed_at: string;
};
function apiBase(): string {
const base = process.env.NEXT_PUBLIC_STATUSPAGE_API_URL;
if (!base) {
throw new Error(
"NEXT_PUBLIC_STATUSPAGE_API_URL ist nicht gesetzt (Umgebungsvariable erforderlich)"
);
}
return base;
}
// fetchOverview holt den Status EINES Moduls unabhaengig vom Erfolg der
// anderen — ein Netzwerkfehler beim Abruf der Gesamtuebersicht wird vom
// Aufrufer (Page-Komponente) abgefangen, sodass ein nicht antwortendes
// Backend die Seite nicht zum Absturz bringt (Akzeptanzkriterium 2).
export async function fetchOverview(): Promise<ModuleStatus[]> {
const res = await fetch(`${apiBase()}/status/overview`, { cache: "no-store" });
if (!res.ok) {
throw new Error(`Uebersicht konnte nicht geladen werden (${res.status})`);
}
return res.json();
}
export async function fetchHistory(name: string): Promise<HistoryEntry[]> {
const res = await fetch(`${apiBase()}/status/history?name=${encodeURIComponent(name)}`, {
cache: "no-store",
});
if (!res.ok) {
throw new Error(`Verlauf konnte nicht geladen werden (${res.status})`);
}
return res.json();
}