prep for the nook

This commit is contained in:
2026-08-26 17:41:57 -04:00
parent 898c891bd5
commit e4a9be4899
27 changed files with 1234 additions and 20 deletions

View File

@@ -0,0 +1,21 @@
/**
* Shared JSON response helpers for the The Nook license API routes.
* Underscore-prefixed file — not a route.
*/
export function json(data: unknown, status = 200): Response {
return new Response(JSON.stringify(data), {
status,
headers: { "Content-Type": "application/json" }
});
}
export function error(message: string, status: number): Response {
return json({ error: message }, status);
}
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
export function isUuid(value: unknown): value is string {
return typeof value === "string" && UUID_RE.test(value);
}