class ContainerBuilder
Since 0.1.0

Fluent builder for IContainer instances.

Collects configuration and provider registrations, then produces a ready-to-use container via build.

Examples

Example 1

const container = new ContainerBuilder()
  .setDefaultScope('singleton')
  .register('db', { useFactory: () => createDb() })
  .register('users', { useClass: UserService, inject: ['db'] })
  .build();

Methods

build(): IContainer

Creates the container with all queued registrations applied.

register<T>(
token: string,
provider: Provider<T>,
options?: ProviderOptions
): this

Queues a provider registration to be applied at build time.

setAutoRegister(enabled: boolean): this

Enables or disables auto-registration fallback to the external resolver.

setDefaultScope(scope: ServiceScope): this

Sets the default lifecycle scope for providers registered without an explicit scope.

Sets the external resolver used when auto-registration is enabled.

Usage

import { ContainerBuilder } from "di-plugin/src/index.ts";