1 import useSWR, { SWRConfiguration } from "swr"; 2 3 import { HealthResponse } from "src/types"; 4 import { swrFetcher } from "src/utils/swr"; 5 6 const pollConfiguration: SWRConfiguration = { 7 refreshInterval: 5 * 60 * 1000, // 5 minutes 8 }; 9 10 export function useHealthCheck(poll = true) { 11 return useSWR<HealthResponse>( 12 "/api/health", 13 swrFetcher, 14 poll ? pollConfiguration : undefined 15 ); 16 } 17