T
TanStack4w ago
other-emerald

Proper way to compose 'request' middleware to get context type inference without duplication?

I noticed that by chaining request middleware in order to get context type inference middleware will be run more than once and am wondering if there's a proper strategy for composing them to get type inference but not duplication. I did see in the docs that for server function middleware that can be deduped by adding it to globals. Here's an example: addSessionToContext - makes session from request available in later context requireSession - checks the context has a session requireUserAdmin - checks context session user role used in a server route middleware array: [addSessionToContext, requireSession, requireUserAdmin]
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?