14 lines
413 B
TypeScript
14 lines
413 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import type { HealthStatus } from "@umt/contracts";
|
|
import { apiData, TTL_SECOND } from "~/lib/api";
|
|
|
|
/** 服务健康状态,15 秒轮询 */
|
|
export function useHealth() {
|
|
return useQuery({
|
|
queryKey: ["health"],
|
|
queryFn: ({ signal }) => apiData<HealthStatus>("/api/v1/health", { signal }),
|
|
refetchInterval: 15 * TTL_SECOND,
|
|
retry: false,
|
|
});
|
|
}
|