Documentation / @zerotal/core / index / App
Variable: App
constApp:object
Defined in: facade/facades/App.ts:49
Static facade for the application container.
Type Declaration
container
Get Signature
get container():
Container
The live IoC container of the running application.
Returns
instance()
readonlyinstance():Application
The running Application instance.
Returns
environment()
readonlyenvironment():Environment
The runtime environment: "web" | "console" | "worker" | "test" | "repl".
Returns
Environment
isProduction()
readonlyisProduction():boolean
Whether the configured app.env is a production environment.
Returns
boolean
isLocal()
readonlyisLocal():boolean
Whether the configured app.env is a local/development environment.
Returns
boolean
make()
readonlymake<T>(token,consumer?):Promise<T>
Resolve a binding — or auto-wire a class via its @inject()
metadata — from the container asynchronously. This is the primary
resolution method.
Type Parameters
T
T
Parameters
token
BindingToken<T>
consumer?
unknown
Returns
Promise<T>
makeSync()
readonlymakeSync<T>(token):T
Resolve a binding synchronously. Only works for value bindings and already-resolved singletons; throws otherwise. Prefer App.make.
Type Parameters
T
T
Parameters
token
BindingToken<T>
Returns
T
build()
readonlybuild<T>(ctor):Promise<T>
Construct a class by auto-wiring its dependencies, ignoring any registered binding for that token. Returns a brand-new instance every call.
Type Parameters
T
T
Parameters
ctor
(...args) => T
Returns
Promise<T>
tryMake()
readonlytryMake<K>(token):ContainerBindings[K] |undefined
Resolve a named binding without throwing — returns undefined when the
token is not registered or cannot be resolved synchronously.
Type Parameters
K
K extends keyof ContainerBindings
Parameters
token
K
Returns
ContainerBindings[K] | undefined
bound()
readonlybound(token):boolean
Whether a token is registered in the container.
Parameters
token
Returns
boolean
bind()
readonlybind<T>(token,factory):Container
Register a transient binding — the factory runs on every resolution.
Type Parameters
T
T
Parameters
token
BindingToken<T>
factory
Factory<T>
Returns
singleton()
readonlysingleton<T>(token,factory):Container
Register a singleton binding — resolved once and cached for the process lifetime.
Type Parameters
T
T
Parameters
token
BindingToken<T>
factory
Factory<T>
Returns
scoped()
readonlyscoped<T>(token,factory):Container
Register a request-scoped binding — resolved once per request scope.
Type Parameters
T
T
Parameters
token
BindingToken<T>
factory
Factory<T>
Returns
value()
readonlyvalue<T>(token,instance):Container
Register an already-constructed value under token.
Type Parameters
T
T
Parameters
token
BindingToken<T>
instance
T
Returns
alias()
readonlyalias(from,to):Container
Make resolving from resolve to instead.
Parameters
from
unknown
to
unknown
Returns
forget()
readonlyforget(token):boolean
Remove a binding. Returns true if a binding existed for the token.
Parameters
token
Returns
boolean
Example
// Auto-wire a service class (resolves its @inject() graph):
const users = await App.make(UsersService);
// Resolve a named binding:
const events = await App.make("events");
// Register during boot (bootstrap/app.ts or a provider):
App.singleton(Clock, () => new SystemClock());