UNPKG

@tanosugi/better-auth-utils

Version:

Better Auth Utils

22 lines (19 loc) 697 B
import { uiLocalesDict } from './chunk-5ZITIWVT.mjs'; // src/api.ts var isValidLocale = (locale) => Object.prototype.hasOwnProperty.call(uiLocalesDict, locale); function getUiLocaleDict(locale) { return isValidLocale(locale) ? uiLocalesDict[locale] : uiLocalesDict.en; } function createUiLocaleHandler({ cacheMaxAge }) { return async function GET(req) { const { searchParams } = new URL(req.url); const locale = searchParams.get("locale") || "en"; const dict = getUiLocaleDict(locale); return Response.json(dict, { headers: { "Cache-Control": `public, max-age=${cacheMaxAge}, immutable` } }); }; } export { createUiLocaleHandler, getUiLocaleDict };