Openstatus www.openstatus.dev
at 0580c562a6f62100a34f50c6aa910ff8fdb7d519 55 lines 1.1 kB view raw
1export type Status = 2 | "operational" 3 | "degraded_performance" 4 | "partial_outage" 5 | "major_outage" 6 | "under_maintenance" 7 | "unknown" 8 | "incident"; 9 10type StatusResponse = { status: Status }; 11 12export const statusDictionary: Record< 13 Status, 14 { label: string; color: string } 15> = { 16 operational: { 17 label: "Operational", 18 color: "bg-green-500", 19 }, 20 degraded_performance: { 21 label: "Degraded Performance", 22 color: "bg-yellow-500", 23 }, 24 partial_outage: { 25 label: "Partial Outage", 26 color: "bg-yellow-500", 27 }, 28 major_outage: { 29 label: "Major Outage", 30 color: "bg-red-500", 31 }, 32 unknown: { 33 label: "Unknown", 34 color: "bg-gray-500", 35 }, 36 incident: { 37 label: "Incident", 38 color: "bg-yellow-500", 39 }, 40 under_maintenance: { 41 label: "Under Maintenance", 42 color: "bg-blue-500", 43 }, 44} as const; 45 46export async function getStatus(slug: string): Promise<StatusResponse> { 47 const res = await fetch(`https://api.openstatus.dev/public/status/${slug}`); 48 49 if (res.ok) { 50 const data = (await res.json()) as StatusResponse; 51 return data; 52 } 53 54 return { status: "unknown" }; 55}