feat: 基础框架搭建完毕
Checks / verify (push) Failing after 2m37s

This commit is contained in:
2026-10-07 09:27:47 +08:00
parent ba6dfffab7
commit bffdb3858b
64 changed files with 326 additions and 332 deletions
+16
View File
@@ -0,0 +1,16 @@
export type ComponentStatus = "ready" | "unavailable" | "not_configured"
export type Health = {
status: "ready" | "not_ready"
checked_at: string
components: { postgresql: { status: ComponentStatus }; redis: { status: ComponentStatus } }
}
export async function getHealth(signal?: AbortSignal): Promise<Health> {
const response = await fetch("/api/v1/system/health", { signal, headers: { Accept: "application/json" } })
if (!response.ok && response.status !== 503) throw new Error(`服务请求失败(${response.status})`)
const data: unknown = await response.json()
if (!data || typeof data !== "object" || !("status" in data) || !("components" in data) || !("checked_at" in data)) throw new Error("服务返回了无效的状态数据")
const health = data as Health
const statuses = ["ready", "unavailable", "not_configured"]
if (!["ready", "not_ready"].includes(health.status) || typeof health.checked_at !== "string" || !statuses.includes(health.components?.postgresql?.status) || !statuses.includes(health.components?.redis?.status)) throw new Error("服务返回了无效的状态数据")
return health
}