tRPCttRPC
Powered by
CoopC
tRPC•3y ago•
4 replies
Coop

Forced router input?

I have a user route which has routes like get, delete, create etc. Some of the routes I require extra data but in all of them, my input contains:
id: z.string()
id: z.string()


I also call this code in all my routes:
const user = await db.query.users.findFirst({
        where: eq(users.id, input.id),
      })
const user = await db.query.users.findFirst({
        where: eq(users.id, input.id),
      })


Is there a way to create a wrapper or middleware that implements route logic like
.input()
.input()
but allows for other routes?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Best way to implement input based validation on a router procedure
JavascriptMickJJavascriptMick / ❓-help
3y ago
Migrating pages router to app router
spreen_coSspreen_co / ❓-help
11mo ago
Incompatible Router Types
RainePRRaineP / ❓-help
3y ago