P-0000: FORMAT.md v1, Prüfskript check_format.py, Viewer-Kopie mit Hinweis bei neuerer Formatversion, Tests format2lint
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
33
viewer/src/lib/api.ts
Normal file
33
viewer/src/lib/api.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// Anbindung an den kleinen Server (server.mjs). Ersetzt die Tauri-Befehle `dev_roadmap` und `dev_klicktests` aus Kanonwerk.
|
||||
export interface ProjectInfo { id: string; name: string; path: string }
|
||||
|
||||
/** Aktuell gewähltes Projekt (Index im Server); die App setzt es, bevor die Ansicht neu lädt */
|
||||
export const session = { project: "0" };
|
||||
|
||||
async function get(path: string): Promise<Response> {
|
||||
const r = await fetch(`/api/${path}${path.includes("?") ? "&" : "?"}project=${encodeURIComponent(session.project)}`, { cache: "no-store" });
|
||||
return r;
|
||||
}
|
||||
|
||||
export async function listProjects(): Promise<ProjectInfo[]> {
|
||||
const r = await fetch("/api/projects", { cache: "no-store" });
|
||||
if (!r.ok) throw new Error(await r.text());
|
||||
return r.json();
|
||||
}
|
||||
|
||||
export async function devRoadmap(): Promise<string> {
|
||||
const r = await get("roadmap");
|
||||
if (!r.ok) throw new Error(await r.text());
|
||||
return r.text();
|
||||
}
|
||||
|
||||
/** KLICKTESTS.md ist optional: fehlt sie, gibt es keinen Tests-Reiter */
|
||||
export async function devKlicktests(): Promise<string> {
|
||||
const r = await get("klicktests");
|
||||
return r.ok ? r.text() : "";
|
||||
}
|
||||
|
||||
export async function devReports(): Promise<{ file: string; text: string }[]> {
|
||||
const r = await get("reports");
|
||||
return r.ok ? r.json() : [];
|
||||
}
|
||||
Reference in New Issue
Block a user