gkline
gkline5mo ago

Union context type to allow incremental upgrade to App router

Hi there. We have a tRPC API that is currently being served from the NextJS Pages router. We're looking to migrate to the App router, and in the process I am being tasked with finding a way to reuse all of our existing routers/routes. I have the new app-router-router setup and serving requests, and now I'm trying to find a way to hook up to our existing routes. The issue is, the two context objects seem to be incompatible. One has the Pages router Req and Res properties, while the other just has the Req property. Otherwise, the types are exactly the same. I have handling so that all of our middleware works with either context type, yet defining base procedures results in a type error. Is there any way I can rectify this, so that for example, our teamProcedure would work on two different types of context? I've managed to figure everything else out, except for this. Thanks! App specs: Node v20.15 tRPC v10.45 Next v14.2
No description
0 Replies
No replies yetBe the first to reply to this messageJoin