You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// index.tsconstapp=newElysia().group("/api",api=>api.use(AccountsController).use(TagGroupsController)).listen(Config.PORT);console.log(`🦊 Elysia is running at http://${app.server?.hostname}:${app.server?.port}`);
So with this setup:
ctx.logger gets overwritten by the last controller (so AccountsController will have TagGroupsController's logger)
ctx.services get overwritten by the last controller in both approaches (direct one and with destruct of the previous state), so ctx.services.accountsService is always undefined, it's only tagGroupsService there
TypeScript types work correctly
How can I deal with that? There is no scope setting for decorate. Everything works fine with derive, but it's weird to have static services / logger creation on every request. What am I doing wrong? Any help is appreciated.
What is the expected behavior?
Expected to have correct logger instance and correct services object in context
What do you see instead?
I see last used controller's logger and last used controller services
Additional information
No response
The text was updated successfully, but these errors were encountered:
What version of Elysia.JS is running?
1.0.20
What platform is your computer?
Darwin 23.1.0 x86_64 i386
What steps can reproduce the bug?
If I have Controller factory as follows, the decorate doesn't work as expected - it gets overwritten every time I run the factory:
Example controllers:
Server start:
So with this setup:
ctx.logger
gets overwritten by the last controller (soAccountsController
will haveTagGroupsController
's logger)ctx.services
get overwritten by the last controller in both approaches (direct one and with destruct of the previous state), soctx.services.accountsService
is alwaysundefined
, it's onlytagGroupsService
thereHow can I deal with that? There is no
scope
setting fordecorate
. Everything works fine withderive
, but it's weird to have static services / logger creation on every request. What am I doing wrong? Any help is appreciated.What is the expected behavior?
Expected to have correct
logger
instance and correctservices
object in contextWhat do you see instead?
I see last used controller's
logger
and last used controllerservices
Additional information
No response
The text was updated successfully, but these errors were encountered: