bill92B
tRPC10mo ago
2 replies
bill92

Use middleware on the router level

Is it possible to apply a middleware to the router level?

I have 4 routers and I would like to apply different middleware to each of them

// Core router
const coreApiRouter = router({
  billing: billingRouter,
  customer: customerRouter,
  appointment: appointmentRouter,
  note: noteRouter,
});


I was thinking on doing something like the above but it's not working

const coreApiRouter = router({
  billing: procedure.use(({ next }) => next()).concat(billingRouter),
});
Was this page helpful?