From 18a24c733d29a0d4d813f6570ed16f733f2996f5 Mon Sep 17 00:00:00 2001 From: notshop Date: Sun, 26 Apr 2026 16:35:04 +0000 Subject: [PATCH] chore: add client/src/lib/queryClient.ts --- client/src/lib/queryClient.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 client/src/lib/queryClient.ts diff --git a/client/src/lib/queryClient.ts b/client/src/lib/queryClient.ts new file mode 100644 index 0000000..edd2422 --- /dev/null +++ b/client/src/lib/queryClient.ts @@ -0,0 +1,24 @@ +import { QueryClient } from "@tanstack/react-query"; + +export const queryClient = new QueryClient({ + defaultOptions: { + queries: { + retry: 1, + staleTime: 30_000, + }, + }, +}); + +export async function apiRequest(method: string, path: string, body?: unknown): Promise { + const res = await fetch(path, { + method, + headers: body ? { "Content-Type": "application/json" } : {}, + body: body ? JSON.stringify(body) : undefined, + credentials: "include", + }); + if (!res.ok) { + const text = await res.text().catch(() => res.statusText); + throw new Error(text || `HTTP ${res.status}`); + } + return res; +}