Skip to content

[V6] Singleton per-request? #4498

Closed Answered by RomainLanz
holoyan asked this question in Help
Apr 5, 2024 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

You can bind an injectable value in your middleware.

handle(ctx: HttpContext, next: NextFn) {
  const scope = new Scope()
  ctx.containerResolver.bindValue(Scope, scope)
}

Then:

@inject()
class MyService {
  constructor(private scope: Scope) {}
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@holoyan
Comment options

@RomainLanz
Comment options

Answer selected by holoyan
@holoyan
Comment options

@thetutlage
Comment options

@holoyan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants