-
-
Notifications
You must be signed in to change notification settings - Fork 478
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.4.1
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What environment are you using
1.3.7
Are you using dynamic mode?
No
What steps can reproduce the bug?
Create two macros, where one macro's resolve intends to use the other macros functionality. As an example, we can create a macro that creates session cookies and (in memory) sessions, and then an auth macro that utilizes this.
import { Elysia } from "elysia";
export const sessionsPlugin = new Elysia().macro({
sessions: {
resolve: () => ({
sessions: {
create: () => {},
get: () => {},
delete: () => {},
},
}),
},
});
export const authPlugin = new Elysia()
.use(sessionsPlugin)
.macro({
auth: {
resolve: ({ sessions, status }) => { // --> type error on sessions
const session = sessions.get(); // --> runtime error because sessions is undefined
// ... some more stuff that is not useful for the example
return { auth: { currentUser: session } };
},
sessions: true,
},
});What is the expected behavior?
I would expect macros to be able to depend upon other macros, this would allow for better abstractions.
Perhaps my understanding of macros is incorrect? Or I'm missing something in the docs, but I searched and didn't find anything.
What do you see instead?
Seemingly impossible to get macros working in the resolve function of other macros.
Additional information
No response
Have you try removing the node_modules and bun.lockb and try again yet?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working