Initial commit

This commit is contained in:
Developer
2026-02-06 21:44:04 -06:00
commit f85e93c7a6
151 changed files with 22916 additions and 0 deletions

23
lib/http.ts Normal file
View File

@@ -0,0 +1,23 @@
import { NextResponse } from "next/server";
import { PublicError, publicMessageFor } from "./errors";
export function ok(data: any = {}) {
return NextResponse.json({ ok: true, ...data });
}
export function fail(err: unknown, opts?: { adminMessage?: string; status?: number; isAdmin?: boolean }) {
const status = opts?.status ?? 400;
if (opts?.isAdmin) {
const msg =
err instanceof PublicError
? err.message
: err instanceof Error
? err.message
: "Unknown error";
return NextResponse.json({ ok: false, message: msg }, { status });
}
// consumer-safe
return NextResponse.json({ ok: false, message: publicMessageFor("GENERIC") }, { status });
}