-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@InRequestScope not returning the same Instance #63
Comments
Navigating through the types docs, i think i've misunderstood the Request Scope. I need an HTTP Request scope, but its not clear to me how could I create such scope with the framework. Is it even possible? I think I would have to create a Build context per HttpRequest, and that it should be in a express middleware function. Do you have any hint for this? |
Same problem here, any help? Thanks! |
@pballester sorry for the very late response. I did this using the new async_hook - AsyncLocalStorage api (node 13+), but I didn't integrate it with typescript-ioc. The code is something like this:
|
Would love to get this working as it just doesn't seem very straight forward. |
I'm using typescript-ioc on server side with nodejs and express, and trying to create an object that holds de logged user, that I should be able to access it in any place on my application.
To do so, i've created the following class:
And i've created an express middleware that would extract the logged user from request, and fill it in LoggedInUserService. But it seems that In the same request, or even in the same function, different instances of LoggedInUserService are retrieve from Container.
When I use Singleton scope, I do get the same Instance.
Do I need to create some configuration for @InRequestScope ? What am I missing?
Thank you
The text was updated successfully, but these errors were encountered: