tRPCttRPC
Powered by
TimKleierT
tRPC•16mo ago•
1 reply
TimKleier

Any guidance on adding middleware at the router level?

I want to apply middleware across all admin routes. I could add middleware to the adminProcedure, but I'd prefer to do so at the router level. I didn't see any info in the docs. How can I accomplish this?
const adminRouter = router({
  secretPlace: adminProcedure.query(() => 'a key'),
  secretPlace2: adminProcedure.query(() => 'b key')
});
const adminRouter = router({
  secretPlace: adminProcedure.query(() => 'a key'),
  secretPlace2: adminProcedure.query(() => 'b key')
});
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

Use middleware on the router level
bill92Bbill92 / ❓-help
11mo ago
Can middleware be used on a router?
aryzingAaryzing / ❓-help
3y ago