Replies: 1 comment
|
The first thing I would change is the plugin graph. Right now the same scoped plugins are mounted multiple times: Pick one composition direction and use each dependency once. For example, if your existing export const media = new Elysia({ prefix: '/media' })
.use(membershipMiddleware)
.get('/', ({ auth, tenant, member }) => ({ auth, tenant, member }))Or split the plugins so |
Uh oh!
There was an error while loading. Please reload this page.
Hi 👋
I'm running into a TypeScript / Eden Treaty issue with Elysia when composing multiple middlewares (auth → tenant → membership).
Runtime behavior works correctly, but Eden completely loses type information and collapses the router to:
I've tried multiple approaches and at this point I genuinely don't know what is causing Eden to break.
What I'm trying to achieve
Current implementation (using
derive)Auth middleware (optional session)
Tenant middleware (depends on auth)
Membership middleware (depends on auth + tenant)
Where Eden breaks
As soon as I compose these middlewares in a router:
Eden loses all typing (
media: any).If I remove any one of the middlewares, Eden typing works again.
Other things I tried
I also tried:
macro+resolveguard({ auth: true })instead of chaining.use()status()vs throwing errorsAll of these resulted in the same Eden typing collapse.
At this point I'm not sure:
derivemiddlewares are allowed to depend on each otherstatus()fromderiveis Eden-safe.use()with derived context is supported at allWhy I'm confused
The documentation shows:
derivemacroresolvebeforeHandle.use()chaining.guard()...but it doesn't clearly explain:
Different examples seem to imply different answers.
My question
Is this
derive+ chained.use()pattern fundamentally incompatible with Eden typing?If so:
deriveintended only for leaf-level context, not dependency chains?Any clarification or official guidance would be really appreciated.
All reactions