mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 23:13:01 -04:00
23 lines
837 B
TypeScript
23 lines
837 B
TypeScript
import { getLocale, loadConfig, loadPronouns, loadTranslator } from '~/server/data.ts';
|
|
import { getPronounExamples, makePublicPronoun } from '~/server/pronouns.ts';
|
|
import { buildPronoun } from '~/src/buildPronoun.ts';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const locale = getLocale(event);
|
|
const [config, translator, pronouns] = await Promise.all([
|
|
loadConfig(locale),
|
|
loadTranslator(locale),
|
|
loadPronouns(locale),
|
|
]);
|
|
checkIsConfigEnabledOr404(config, 'pronouns');
|
|
|
|
const pronoun = buildPronoun(pronouns, getRouterParam(event, 'pronoun') ?? null, config, translator);
|
|
if (!pronoun) {
|
|
throw createError({
|
|
status: 404,
|
|
statusMessage: 'Not Found',
|
|
});
|
|
}
|
|
return makePublicPronoun(pronoun, await getPronounExamples(event));
|
|
});
|