Generic Zod as Input Type
I'm not positive if this is a TRPC question, typescript in general, or failure to understand Zod in this usecase. Our API has a several endpoints that all work the same way just pass in different payloads. I'm trying to create a single function to assign to all my TRPC routes:
I'm not sure what should be in the
input
section to make this work?2 Replies
You want a Router Factory, and potentially the polymorphism utilities
I have a dev.to post on it if you google for “trpc router factories” but it’s a more advanced topic so we don’t really push this in the docs
Inputs themselves can’t be generic though, you need to have multiple routers
Got it thanks Nick!