NodeDiAdapter · Node.js API
type NodeDiAdapter = object;Node.js AsyncLocalStorage adapter instance created by createNodeDi.
Properties
Section titled “Properties”getRootContainer
Section titled “getRootContainer”readonly getRootContainer: () => Container;Returns the long-lived root container.
Returns
Section titled “Returns”getRequestContainer
Section titled “getRequestContainer”readonly getRequestContainer: () => Container;Returns the container bound to the current async request scope.
Returns
Section titled “Returns”Throws
Section titled “Throws”NodeRequestScopeError outside an active request scope or after it
has been disposed.
createRequestContainer
Section titled “createRequestContainer”readonly createRequestContainer: (extraProviders?) => Container;Creates a fresh child container without binding it to async context.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
readonly |
Returns
Section titled “Returns”runWithRequestContainer
Section titled “runWithRequestContainer”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<Awaited<TResult>>
disposeRootContainer
Section titled “disposeRootContainer”readonly disposeRootContainer: () => Promise<void>;Disposes cached instances owned by the root container.
Returns
Section titled “Returns”Promise<void>