Refactor backend to SQLModel; reset schema; add Company OS endpoints

This commit is contained in:
Abhimanyu Saharan
2026-02-01 23:16:56 +05:30
parent b37e7dd841
commit aa6b0c807b
56 changed files with 867 additions and 450 deletions

24
frontend/src/lib/api.ts Normal file
View File

@@ -0,0 +1,24 @@
export function apiUrl(path: string) {
const base = process.env.NEXT_PUBLIC_API_URL;
if (!base) throw new Error("NEXT_PUBLIC_API_URL is not set");
return `${base}${path}`;
}
export async function apiGet<T>(path: string): Promise<T> {
const res = await fetch(apiUrl(path), { cache: "no-store" });
if (!res.ok) throw new Error(`GET ${path} failed (${res.status})`);
return (await res.json()) as T;
}
export async function apiSend<T>(
path: string,
opts: { method: "POST" | "PATCH" | "DELETE"; body?: unknown }
): Promise<T> {
const res = await fetch(apiUrl(path), {
method: opts.method,
headers: opts.body ? { "Content-Type": "application/json" } : undefined,
body: opts.body ? JSON.stringify(opts.body) : undefined,
});
if (!res.ok) throw new Error(`${opts.method} ${path} failed (${res.status})`);
return (await res.json()) as T;
}