Repository Public
1import { isLocale, type Locale } from "./i18n";23export const localeOf = (url: URL): Locale => { const l = url.searchParams.get("locale") ?? "en"; return isLocale(l) ? l : "en"; };4export const json = (data: unknown, init: ResponseInit & { cache?: string } = {}) =>5 Response.json(data, { ...init, headers: { "Cache-Control": init.cache ?? "public, max-age=30, stale-while-revalidate=120", ...(init.headers ?? {}) } });6export const bad = (error: string, status = 400) => Response.json({ error }, { status, headers: { "Cache-Control": "no-store" } });7