UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

16 lines (9 loc) 426 B
import { TRPCError } from '@trpc/server'; import { getJWTPayload } from '@/utils/server/jwt'; import { edgeTrpc } from '../init'; export const jwtPayloadChecker = edgeTrpc.middleware(async (opts) => { const { ctx } = opts; if (!ctx.authorizationHeader) throw new TRPCError({ code: 'UNAUTHORIZED' }); const jwtPayload = await getJWTPayload(ctx.authorizationHeader); return opts.next({ ctx: { jwtPayload } }); });