bill92
bill923d ago

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,
});
// 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),
});
const coreApiRouter = router({
billing: procedure.use(({ next }) => next()).concat(billingRouter),
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?