chore: preserve initial reconstruction prototype

This commit is contained in:
2026-07-31 18:51:38 +01:00
commit a2f9e472ea
26 changed files with 8874 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import { z } from "zod";
const envSchema = z.object({
OLLAMA_BASE_URL: z.string().url(),
OLLAMA_MODEL: z.string().min(1),
});
export function getConfig() {
const parsed = envSchema.safeParse({
OLLAMA_BASE_URL: process.env.OLLAMA_BASE_URL,
OLLAMA_MODEL: process.env.OLLAMA_MODEL,
});
if (!parsed.success) {
return { ok: false, error: parsed.error.flatten().fieldErrors };
}
return { ok: true, config: parsed.data };
}
export function assertConfig() {
const result = getConfig();
if (!result.ok) {
throw new Error(
"Invalid configuration:\n" +
Object.entries(result.error).map(([k, v]) => ` ${k}: ${v}`).join("\n")
);
}
return result.config;
}