跳转到内容
简体中文

Config

此内容尚不支持你的语言。

Defined in: src/config/Config.ts:137

get [CONFIG_BRAND](): true

Defined in: src/config/Config.ts:174

The brand — see CONFIG_BRAND. On the prototype, so it is never an own key.

true

atPath(path): Config

Defined in: src/config/Config.ts:588

Wrap the tree under the given path: {a:{b:1}}.atPath(“x.y”) → {x:{y:{a:{b:1}}}}.

string

Config


getBoolean(path): boolean

Defined in: src/config/Config.ts:503

string

boolean


getBytes(path): number

Defined in: src/config/Config.ts:531

Byte count: a whole number of bytes.

A bare number never reaches parseSize, which refuses a size that is not whole, so the number branch checks it here — where, unlike the parser, it can name the key. It used to hand a bare 10.5 back as it was (#1728). The check comes after requireFinite and passes Infinity, the size that function lets through at the one key documenting it as “no cap”.

string

number


getConfig(path): Config

Defined in: src/config/Config.ts:566

string

Config


getDuration(path): number

Defined in: src/config/Config.ts:515

Duration in milliseconds.

string

number


getInt(path): number

Defined in: src/config/Config.ts:482

string

number


getList(path): ConfigValue[]

Defined in: src/config/Config.ts:554

string

ConfigValue[]


getNumber(path): number

Defined in: src/config/Config.ts:488

string

number


getObject(path): ConfigObject

Defined in: src/config/Config.ts:560

string

ConfigObject


getString(path): string

Defined in: src/config/Config.ts:475

string

string


getStringList(path): string[]

Defined in: src/config/Config.ts:544

string

string[]


hasPath(path): boolean

Defined in: src/config/Config.ts:455

string

boolean


merge(overlay): Config

Defined in: src/config/Config.ts:582

Inverse of withFallback — layer overlay on top.

Config

Config


toJSON(): ConfigObject

Defined in: src/config/Config.ts:631

ConfigObject


withFallback(other): Config

Defined in: src/config/Config.ts:576

Merge other underneath this config — i.e. values defined here win, keys that only exist in other are filled in.

Config

Config


static empty(): Config

Defined in: src/config/Config.ts:178

Config


static fromObject(obj): Config

Defined in: src/config/Config.ts:209

A config built from a plain object of overrides.

This copy’s own Config comes back as it is. Anything else that is not a plain object is refused, because the fallback used to be worse than an error: a class instance passed the plain-object test, its own fields were read as the tree, and the keys the caller meant went unread without a word — an empty Map is an empty config. A Config built by another copy of actor-ts is the case that matters, and it gets its own message, since its layers and the secret paths the boot dump withholds are private to the copy that built it: reading only its tree could print a secrets-file value in clear text.

The same defect had two more routes, closed here for every caller — ActorSystemOptions.withConfig and Config.load({ overrides }) among them (#1473). A spread of a Config ({ ...config }) passes the plain-object test, because the brand sits on the prototype a spread does not copy, and is refused by name; and a class instance below the top level is refused, naming its path, as one at the top level is.

unknown

Config


static load(options?): Config

Defined in: src/config/Config.ts:311

Load the standard config chain. Precedence (highest first):

  1. overrides passed in code.
  2. The secrets file’s active profile — its profiles.<profile> block.
  3. The secrets file, resolved via secretsConfPath → process.env.ACTOR_TS_SECRETS_CONF → ./secrets.conf in CWD.
  4. The application file’s active profile.
  5. application.conf resolved via appConfPath → process.env.ACTOR_TS_CONFIG → ./application.conf in CWD.
  6. The project reference.conf’s active profile.
  7. The project’s own reference.conf, resolved via referenceConfPath → process.env.ACTOR_TS_REFERENCE_CONFIG → ./reference.conf in CWD (#1785).
  8. reference.conf bundled with this package.

The profile is profile → process.env.ACTOR_TS_PROFILE → none, and a name no file defines is refused rather than read as “no overlay”. Every file is optional: a path with no file behind it is an empty layer, and false for a path reads no such file at all. A file that is there and cannot be loaded is refused naming the file and what made load read it — the files in the working directory are read whenever nothing names others.

Substitutions read, in order: the file’s own keys, with its active profile laid over its root before they resolve — so an alias in the root follows the profile, and an inactive profile is never resolved at all — then the resolved layers beneath it, then the real environment, then the variables of a .env file (#1785). Downward only: application.conf may read a key the project reference.conf sets, but a lower file never sees a higher one, so there is no late binding and each layer still holds exactly what its file produced. The .env file is found through the option, then the real ACTOR_TS_ENV_FILE, then ./.env, and may itself name the other files and the profile; it never writes process.env.

LoadOptions = {}

Config


static loadReference(): Config

Defined in: src/config/Config.ts:447

Config


static parseFile(path): Config

Defined in: src/config/Config.ts:185

string

Config


static parseString(source): Config

Defined in: src/config/Config.ts:180

string

Config