Every method, every argument, every default. The TypeScript definitions
ship with the package, so an editor has all of this too — this page is
what a reader wants when the editor is not the question.
the section this configuration reads ([db] in a TOML file). It also names the environment prefix — env("APP_") reads APP_DB_* — and every diagnostic. "" is a configuration with nothing to call itself, which goes with wholeDocument()
validate
none
what turns a resolved object into the value the program reads. Omitted, the document is the value — see Schemas
secrets
none
dotted paths whose values must never reach a diagnostic. A redacted or fingerprint cache is refused without them
fields
none
the keys the schema declares, for the unknown-key report. Without it check() says it compared nothing
The generic parameter is whatever validate returns, so current() is
T with nothing cast.
Each returns the configuration, so they chain. All of them are refused
after the first load — a source added later would take effect on the next
reload and nowhere in the document that is serving.
Call
What it adds
file(path)
a file. Files merge left to right, key by key
discover(name, paths)
look for name in each of paths, in order
env(prefix)
PREFIX_KEY_* from the environment
nest(separator)
what spells nesting in a variable name; __ by default
allowEmptyEnv()
treat an empty variable as a value rather than as absent
strictEnv()
refuse an ambiguous spelling — off, yes, none — instead of guessing
wholeDocument()
the file has no section header: its whole document is this section
envFile(path)
a .env, which sits just below the real environment
secretsDir(path)
one file per key, as Docker and Kubernetes mount
profileEnv(variable)
which variable names the profile to select
cache(path, mode)
the last-known-good cache: "full", "redacted" or "fingerprint"
Pins values for the duration of the block and puts back what it found —
so a nested block does not drop the outer one's pin on the way out. No
filesystem and no environment involved.