Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 42x 80x 80x 80x 74x 74x 2x 2x 3x 3x 3x 2x 2x 1x | import { create } from 'zustand'
import { apiClient } from '@/lib/axios'
interface ServiceStatus {
name: string
status: 'healthy' | 'degraded' | 'unhealthy'
message?: string | null
}
interface HealthState {
status: 'healthy' | 'degraded' | 'unhealthy'
responseTime: number | null
lastChecked: number | null
apiVersion: string | null
services: ServiceStatus[]
fetchHealth: () => Promise<void>
}
export const useHealthStore = create<HealthState>()((set) => ({
status: 'healthy',
responseTime: null,
lastChecked: null,
apiVersion: null,
services: [],
fetchHealth: async () => {
const start = performance.now()
try {
const { data } = await apiClient.get('/health')
const elapsed = Math.round(performance.now() - start)
set({
status: data.status,
responseTime: elapsed,
lastChecked: Date.now(),
apiVersion: data.version ?? null,
services: data.services ?? [],
})
} catch {
set({
status: 'unhealthy',
responseTime: null,
lastChecked: Date.now(),
apiVersion: null,
services: [],
})
}
},
}))
|