/
githubmirror
/
trpc
Обзор
Документация
Войти
/
githubmirror
/
trpc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/fastify-server/src/server/router/context.ts
13 строк
395 B
Alex / KATT
chore: remove overzealous destructuring (#6930)
05 сен 2025, 19:46
Не верифицирован
05 сен 2025, 19:46
029196b
Код
Авторство
О чём код?
import type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify'; export interface User { name: string[] | string; } export function createContext(opts: CreateFastifyContextOptions) { const user: User = { name: opts.req.headers.username ?? 'anonymous' }; return { req: opts.req, res: opts.res, user }; } export type Context = Awaited<ReturnType<typeof createContext>>;