Something went wrong. Try again.
🌿 Collaborative wiki on ATProto forked from juprodh.me/lichen.wiki
Something went wrong. Try again.
12345678910111213141516171819202122import { Elysia } from "elysia";import { resolveRequestContext } from "../lib/access-resolve.ts";import { t } from "../lib/i18n/index.ts";
/** * Injects the base request context (`ctx`) and the resolved translation map * (`msg`) into every route handler. Avoids repeating: * * const ctx = await resolveRequestContext(request); * const msg = t(ctx.locale); * * at the top of every handler. Routes that need a wiki-scoped context still * call `resolveWikiContext` explicitly. */export const contextPlugin = new Elysia({ name: "context" }).derive( { as: "global" }, async ({ request }) => { const ctx = await resolveRequestContext(request); return { ctx, msg: t(ctx.locale) }; },);