mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 13:19:09 +03:00
* chore(studio): swap react-query to object syntax * Fix small issues found * Fix realtime settings * Nit --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
27 lines
910 B
TypeScript
27 lines
910 B
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { platformKeys } from './keys'
|
|
|
|
export type PlatformStatusResponse = {
|
|
isHealthy: boolean
|
|
}
|
|
|
|
export async function getPlatformStatus(signal?: AbortSignal) {
|
|
const { data, error } = await get('/platform/status', { signal })
|
|
if (error) handleError(error)
|
|
return { isHealthy: (data as any).is_healthy } as PlatformStatusResponse
|
|
}
|
|
|
|
export type PlatformStatusData = Awaited<ReturnType<typeof getPlatformStatus>>
|
|
export type PlatformStatusError = unknown
|
|
|
|
export const usePlatformStatusQuery = <TData = PlatformStatusData>(
|
|
options: UseQueryOptions<PlatformStatusData, PlatformStatusError, TData> = {}
|
|
) =>
|
|
useQuery<PlatformStatusData, PlatformStatusError, TData>({
|
|
queryKey: platformKeys.status(),
|
|
queryFn: ({ signal }) => getPlatformStatus(signal),
|
|
...options,
|
|
})
|