Function: preload()
preload<
C>(container,keys?):Promise<void>
Defined in: src/utils/preload.ts:24
Resolves services up front, for example at startup, so configuration errors surface immediately. Without keys it resolves every visible service; pass a list of keys or a predicate to narrow it.
The returned promise settles once the async services (factories that return promises, and every service of an AsyncDIContainer) are created, and rejects with the first failure: await it. Synchronous failures of a sync container still throw immediately.
Type Parameters
C
C extends ServiceProvider<{ }> | AsyncServiceProvider<{ }>
Parameters
container
C
keys?
readonly (keyof ContainerServices<C>)[] | ((key) => boolean)
Returns
Promise<void>
Example
ts
await preload(app); // everything
await preload(app, ['db', 'cache']);
await preload(app, (key) => String(key).startsWith('Billing.'));