Support detection
runInRequestScope still runs the callback but scoped resolution uses explicit scope objects when ALS is unavailable.
Express / Connect middleware
brushyRequestScope creates a unique scope per request and clears scoped instances when the response finishes.
Options
Manual scope (scripts & tests)
RequestScopeOptions
object
Custom scope key. Auto-generated when omitted.
Container
Container to clean up. Defaults to registry default.
(scope) => void
Called when scope is entered.
() => void
Custom cleanup instead of
clearRequestScope.boolean
default:"false"
Skip automatic scope cleanup on exit.
getActiveScope
containerRegistry.getContainer() uses the active scope to pick scoped containers when registered.
Register scoped services
Fastify & async handlers
UserunInRequestScopeAsync inside route handlers when middleware is not available: