Neatly extract tRPC middleware to make it reusable

Does anybody have a snippet for neatly extracting a tRPC middleware, while also maintaining all the typesafety? I was able to hack something by importing MiddlewareFunction and extending a new interface from the ProcedureParams, imported from @trpc/server, omitting the _ctx_out and _input_out and replacing with mines, but it doesn't seem the right way.
2 Replies
Sebastian
Sebastian•13mo ago
up
FleetAdmiralJakob 🗕 🗗 🗙
Hey @sebys7 , I'm stuck in a problem related to the middleware and I think you know the answer to my problem. How does this ctx thingy work? Like why is it of type :{} and how can I get data out of it?