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" } },
configSources: { file: false },
bootLibrariesFirst: true,
loggerOptions: { mergeData: { env: "production" } },
});

Options reference​

FieldTypeDefaultDescription
configurationinput-shaped partial configuration—Early schema/legacy input seed; later enabled loaders can override it
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
handleGlobalErrorsbooleantrueReserved for host-level error handling behavior
showExtraBootStatsbooleanfalsePrint per-service construction times after boot
envFilestring".env"Select the dotenv file used by environment loading
configSourcesPartial<Record<DataTypes, boolean>>env/argv on, file offEnable or disable individual loader channels

configuration​

configuration is an input-shaped seed applied while module definitions are registered, before the source loaders run. For schema entries, its value type is the provider input type. It is not a highest-priority override: enabled environment, argv, file, or custom loaders can replace it.

import { Type } from "typebox";
import { CreateApplication } from "@digital-alchemy/core";

const MY_APP = CreateApplication({
name: "my_app",
configuration: {
RETRIES: { schema: Type.Integer({ default: 3 }) },
},
services: {},
});

await MY_APP.bootstrap({
configuration: {
my_app: { RETRIES: 5 },
},
});

A schema transform or codec may accept a different input type than the output eventually injected into config. See Schema-backed Configuration.

configSources​

Normal bootstrap enables the env and argv loaders by default. The file loader is opt-in. Custom loader names are enabled unless explicitly set to false:

await MY_APP.bootstrap({
configSources: {
env: true,
argv: false,
file: true,
remote: false,
},
});

These switches control loader channels, not explicit configuration values or the output-shaped set() and merge() APIs. An entry-level source allow-list further restricts which loader can set that key.

The file loader reads JSON, YAML/YML, and INI. Select its path with --config path or the legacy boilerplate.CONFIG input. It is separate from dotenv loading: envFile and --env-file select a dotenv file that populates process.env for the environment loader.

For source precedence and key lookup, see Config Sourcing.

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 to be established before their own service function body runs.

appendLibrary / appendService​

These options add libraries or services that were not declared in the original CreateApplication call. They are useful for test helpers, plugins, and runtime extensions. A same-name appended library replaces the existing library.

loggerOptions​

Fine-tune the built-in logger without replacing it. See Project Tuning for the field reference.

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

customLogger​

Replace the built-in logger with your own GetLogger implementation. This is useful for integrating with an external logging system.

Process exit codes​

The framework registers SIGTERM and SIGINT handlers. On signal receipt it runs the shutdown sequence before exiting:

EventExit code
Bootstrap error in normal app mode1 (EXIT_ERROR)
SIGINT (Ctrl+C)130
SIGTERM143

Normal application exit does not call process.exit(); Node exits naturally after lifecycle callbacks and resources finish.

Common errors​

Error causeWhat it means
DOUBLE_BOOTbootstrap() was called on an already-running application
BAD_SORTA circular dependency exists between libraries
MISSING_DEPENDENCYA library dependency is not in the application graph
MISSING_PRIORITY_SERVICEA name in priorityInit is not in services
REQUIRED_CONFIGURATION_MISSINGA legacy required: true entry is undefined after loading
CONFIG_SCHEMA_INVALIDA winning schema input is missing or fails native validation
CONFIG_SCHEMA_PROCESSING_FAILEDA schema provider operation failed
CONFIG_SCHEMA_PEER_MISSING / CONFIG_SCHEMA_PEER_BROKENTypeBox cannot be loaded or its value surface is unusable

Schema entries do not use CONFIG_SCHEMA_REQUIRED; a missing bare schema value is reported as CONFIG_SCHEMA_INVALID. See Schema failures.