T
tRPC

โ“-help

How to get the type of context after middleware context extension?

Ccha0sg0d2/6/2024
I have a middleware where I validate and set a userId. My router knows that userId is no longer undefined, but I need to pass the route context to another function. How do I set the input type for that function such that userId is no longer undefined?
NNeoBean2/17/2024
I have the same question.
Nnlucas2/17/2024
Any reason that function needs coupling to your context types at all? It may seem like the lazy and easy way, but itโ€™s usually best to define your interfaces properly Service classes etc shouldnโ€™t be aware of tRPC
NNeoBean2/17/2024
I dont see a valid reason or requirement. but the lazy way may sometime feel intuitive to tell myself this function belongs strictly to these contexts. I agree with you ๐Ÿ‘
Nnlucas2/17/2024
Yeah, the way I would do it if I wanted lazy, would be to break apart my context types into somewhere central, build my context types from there, and then at least have that stuff consumable/composable for service classes but for userId:string I suspect you don't need a UserId type exported from anywhere ๐Ÿ˜›

Looking for more? Join the community!

T
tRPC

โ“-help

Join Server
Recommended Posts
what am i doing wrong?My turbo repo containing expo-clerk-trpc does NOT work. and I've tried everything I have no idea whaReusable Component to take router as props / dependency injection. How to type?for example: ```ts export const Content = async ({ api }) => { const items = await api.getAll.quertRPC mutate call firing two requests with custom linkNode: 18.16 tRPC: 10.38.0 pnpm What's wrong with this custom link that's causing it's addition to aIssue with Fastify / tRPC / AngularWe are trying to setup Angular project with tRPC. In Angular we get following error: ``` Error: nodDrizzle query not working only inside trpcMy drizzle query works inside a regular nextjs api route. The same query running inside trpc throws Server freezes when doing mutations...I have the exact same issue as mentioned in this post: https://discord-questions.trpc.io/m/117697170Create Wrapper only for Procedures that support Infinite QueryGreetings, I'm attempting to create a help that will handle some generic logic I desire for a seriWhy am I getting 'Argument type is not assignable to parameter type ProcedureResolver<unknown>'?I have this warning in my editor (jetbrains InteliJ): ``` Argument type () => any[] is not assignabEfficient way to use tRPC client with auth headers from secure storageWondering if anyone has a recommended pattern on caching the deviceId / authHeader using a React ConUsing tRPC with Expo API Routes feature?Is there a possibility to merge "tRPC Express Adapter" with "Expo API Route Express Deployment"? tRTRPC not working on multi tenant appEverything works on localhost. When I deploy it on the vercel None of the mutations work. Every qTRPCClientError: Unable to transform response from serverHi ๐Ÿ™‚ I've just started - so nothing more than boiler plate code but for some reason it doesn't workoptimistic updates tRPC v11 + TanStack Query v5I am reading https://tanstack.com/query/latest/docs/framework/react/guides/optimistic-updates#if-theT3 Stack TRPC used in Server ActionsIs there issues using the server calls of TRPC in a nextjs server action? I am seeing weird issues wHow do I setup subscriptions with websockets in Next.js 14 app router?All I've found were some older examples for the pages router which for me were not very understandabWhy is my tRPC + Next 14 (app router) data fetching pattern not refreshing the UI?### Goals of this post: - to know why my UI is not refreshing after i mutate the backend - tUsing tRPC in Next.js MiddlewareHello, I am quite new to tRPC so forgive me if I'm asking something quite obvious/dumb. I was introneed help refreshing websocketWe currently are using tRPC w/ react and websockets. Weโ€™re using the URL of the websocket as the aut