import ky from "ky"; /** * Typed HTTP client built on ky. * Use openapi-fetch alongside this when you have a generated OpenAPI * schema (see openapi-fetch docs: `createClient({ baseUrl })`). */ export const apiClient = ky.create({ prefix: "/api", timeout: 15_000, retry: { limit: 2, methods: ["get"], statusCodes: [408, 429, 500, 502, 503, 504], }, }); export const http = { get: (url: string, init?: RequestInit) => apiClient.get(url, init).json(), post: (url: string, body?: unknown, init?: RequestInit) => apiClient.post(url, { json: body, ...init }).json(), put: (url: string, body?: unknown, init?: RequestInit) => apiClient.put(url, { json: body, ...init }).json(), patch: (url: string, body?: unknown, init?: RequestInit) => apiClient.patch(url, { json: body, ...init }).json(), delete: (url: string, init?: RequestInit) => apiClient.delete(url, init).json(), };