feat(frontend): contract types + REST client (MSW-tested)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 12:13:50 +02:00
co-authored by Claude Sonnet 4.6
parent 7e42ac11ef
commit 913ac30137
10 changed files with 147 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
const BASE = import.meta.env.VITE_BACKEND_URL ?? "http://localhost:8787";
export async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
const res = await fetch(`${BASE}${path}`, {
headers: { "content-type": "application/json" },
...init,
});
if (!res.ok) throw new Error(`${res.status} ${await res.text().catch(() => "")}`);
return res.status === 204 ? (undefined as T) : ((await res.json()) as T);
}
export { BASE };