Skip to main content
Besides automatic request scope, @brushy/di-core exposes explicit scope APIs for tests, background jobs, and non-HTTP workflows.

createScope(scopeKey?)

Returns a ScopedContainer bound to a scope object:
Pass a custom scopeKey to share a bucket across callers:

ScopedContainer API

dispose() calls container.clearScopedInstances(scopeKey).

Low-level scope bucket

When to use explicit scopes

Cleanup

Request scope middleware and runInRequestScope call container.clearRequestScope() on exit unless skipRequestScopeCleanup: true. For manual scopes, always call scope.dispose() or clearScopedInstances when the unit of work ends.