Skip to content

NodeDiAdapter · Node.js API

type NodeDiAdapter = object;

Node.js AsyncLocalStorage adapter instance created by createNodeDi.

readonly getRootContainer: () => Container;

Returns the long-lived root container.

Container


readonly getRequestContainer: () => Container;

Returns the container bound to the current async request scope.

Container

NodeRequestScopeError outside an active request scope or after it has been disposed.


readonly createRequestContainer: (extraProviders?) => Container;

Creates a fresh child container without binding it to async context.

Parameter Type

extraProviders?

readonly Provider[]

Container


readonly runWithRequestContainer: <TResult>(options) => Promise<Awaited<TResult>>;

Runs work inside a fresh child container, binds it to AsyncLocalStorage, and disposes it after the callback settles.

Type Parameter

TResult

Parameter Type

options

RunWithRequestContainerOptions<TResult>

Promise<Awaited<TResult>>


readonly disposeRootContainer: () => Promise<void>;

Disposes cached instances owned by the root container.

Promise<void>