feature: Degraded Operations Visibility

This commit is contained in:
voltsrage
2026-06-23 23:18:31 +08:00
parent 940e27c0ac
commit 4399996448
81 changed files with 3949 additions and 323 deletions
+26
View File
@@ -52,4 +52,30 @@ export const api = {
method: 'POST',
body: body !== undefined ? JSON.stringify(body) : undefined,
}),
put: (path, body) => request(path, {
method: 'PUT',
body: body !== undefined ? JSON.stringify(body) : undefined,
}),
patch: (path, body) => request(path, {
method: 'PATCH',
body: body !== undefined ? JSON.stringify(body) : undefined,
}),
delete: async (path) => {
const res = await fetch(`${BASE_URL}${path}`, {
method: 'DELETE',
headers: authHeaders(),
})
if (res.status === 401) {
throw new Error('Session expired — please log in again.')
}
if (res.status === 204) return null
const envelope = await res.json()
if (!res.ok || !envelope.success) {
const msg = envelope.error?.message ?? `API ${res.status}: ${path}`
throw new Error(msg)
}
return envelope.data ?? null
},
}
export { BASE_URL, authHeaders }