Skip to main content

Bootstrap Options

bootstrap() accepts an optional BootstrapOptions object. All fields are optional.

await MY_APP.bootstrap({
configuration: { boilerplate: { LOG_LEVEL: "debug" } },
bootLibrariesFirst: true,
loggerOptions: { mergeData: { env: "production" } },
});

Options reference​

FieldTypeDefaultDescription
configurationPartialConfiguration—Override config values at highest priority
bootLibrariesFirstbooleanfalseBoot libraries through Bootstrap before wiring app services
appendLibraryTLibrary | TLibrary[]—Add extra libraries after construction
appendServiceServiceMap—Add extra services to the application
loggerOptionsLoggerOptions—Fine-tune the built-in logger
customLoggerGetLogger—Replace the built-in logger entirely
handleGlobalErrorsbooleantrueCatch uncaught exceptions and unhandled rejections
showExtraBootStatsbooleanfalsePrint per-service construction times after boot
envFilestring".env"Path to .env file for config sourcing
configSourcesPartial<Record<DataTypes, boolean>>all trueEnable/disable specific config loaders

configuration​

Provides config values at the highest priority — overrides env, argv, and file sources. Uses the same PartialConfiguration type as .configure() in TestRunner.

await MY_APP.bootstrap({
configuration: {
boilerplate: { LOG_LEVEL: "warn" },
my_app: { DATABASE_URL: "postgres://localhost/mydb", PORT: 5432 },
},
});

bootLibrariesFirst​

By default, all services (library and application) are wired first, then lifecycle stages run for everything together. With bootLibrariesFirst: true, the sequence changes:

Use bootLibrariesFirst: true when application services need library resources (a database connection, a cache client) to be fully established before their own service function body runs — not just before a lifecycle callback.

appendLibrary / appendService​

Adds libraries or services that weren't declared in the original CreateApplication call. Useful for test helpers, plugins, or runtime-determined extensions. If a name collides with an existing library or service, the appended version takes priority.

loggerOptions​

Fine-tune the built-in logger without replacing it. See Project Tuning for all LoggerOptions fields.

loggerOptions: {
mergeData: { env: process.env.NODE_ENV, host: hostname() },
ms: true,
counter: false,
}

customLogger​

Replace the built-in logger with your own implementation. Must implement the GetLogger interface. Useful for integrating with external logging systems (Datadog, OpenTelemetry).

configSources​

Disable specific config loaders. By default all sources are enabled. Setting a source to false prevents that loader from running.

configSources: {
env: false, // ignore environment variables
argv: false, // ignore command-line arguments
}

Process exit codes​

The framework registers SIGTERM and SIGINT handlers automatically. On signal receipt, it runs the full shutdown sequence then exits with the appropriate code:

EventExit code
Bootstrap error1 (EXIT_ERROR)
SIGINT (Ctrl+C)130
SIGTERM143

Normal application exit (all lifecycle callbacks complete without error) does not call process.exit() — the Node.js process exits naturally.

Common errors​

Error causeWhat it means
DOUBLE_BOOTbootstrap() called on an already-running application
BAD_SORTCircular dependency between libraries
MISSING_DEPENDENCYA library's depends entry is not in the app's libraries array
REQUIRED_CONFIGURATION_MISSINGA required: true config entry has no value at PostConfig
MISSING_PRIORITY_SERVICEA name in priorityInit doesn't exist in services