mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
* Deprecate use of getWithTimeout, refactor BuildingState and RestoringState to use RQ * Refactor profile-create-mutation to use data/fetchers, and edge-function-status-query to use fetch * Shift post from lib/common/fetch, refactor bucket-object-download-mutation * Address feedback * Minor fix * Smol fix
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import type { ResponseError } from 'types'
|
|
import { serviceStatusKeys } from './keys'
|
|
|
|
export type EdgeFunctionServiceStatusVariables = {
|
|
projectRef?: string
|
|
}
|
|
|
|
export async function getEdgeFunctionServiceStatus(signal?: AbortSignal) {
|
|
try {
|
|
const res = await fetch('https://obuldanrptloktxcffvn.supabase.co/functions/v1/health-check', {
|
|
method: 'GET',
|
|
signal,
|
|
})
|
|
const response = await res.json()
|
|
return response as { healthy: boolean }
|
|
} catch (err) {
|
|
return { healthy: false }
|
|
}
|
|
}
|
|
|
|
export type EdgeFunctionServiceStatusData = Awaited<ReturnType<typeof getEdgeFunctionServiceStatus>>
|
|
export type EdgeFunctionServiceStatusError = ResponseError
|
|
|
|
export const useEdgeFunctionServiceStatusQuery = <TData = EdgeFunctionServiceStatusData>(
|
|
{ projectRef }: EdgeFunctionServiceStatusVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<EdgeFunctionServiceStatusData, EdgeFunctionServiceStatusError, TData> = {}
|
|
) =>
|
|
useQuery<EdgeFunctionServiceStatusData, EdgeFunctionServiceStatusError, TData>(
|
|
serviceStatusKeys.edgeFunctions(projectRef),
|
|
({ signal }) => getEdgeFunctionServiceStatus(signal),
|
|
{
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|