import axios, { type AxiosInstance } from 'axios'

const client: AxiosInstance = axios.create({
  baseURL: '/rest',
  headers: { Accept: 'application/json' },
  timeout: 15_000,
})

export async function getJson<T>(path: string, params?: Record<string, string>): Promise<T> {
  const { data } = await client.get<T>(path, { params })
  return data
}

export { client as postgrestClient }
