env

5 modules

  • env/dotenv.ts

    Dotenv file parsing and loading.

    Provides parse_dotenv for parsing dotenv-format strings and load_env_file for reading and parsing env files from disk.

  • env/load.ts

    Generic environment loading from Zod schemas.

    Provides load_env which iterates Zod schema keys, gets env values, and validates. Apps handle error messages themselves (they're always app-specific).

  • env/mask.ts

    Environment value display formatting with secret masking.

    Provides utilities for safely displaying env values in logs and startup summaries, masking secrets with a placeholder.

  • env/resolve.ts

    Environment variable $$VAR$$ resolution suite.

    Resolves $$VAR$$ references in strings and object trees, scans configs for references, and validates/formats missing vars.

    The double-dollar bookending syntax is: - Visually distinct from shell $VAR syntax - Unambiguous about variable boundaries - Easy to grep: grep '\$\$' - Fails loud if accidentally shell-processed ($$=PID in shell)

    Syntax

    - $$VAR$$ — required reference. Missing or empty fails validation (see validate_env_vars). - $$?VAR$$ — optional reference. Missing or empty resolves to the empty string and passes validation. Use for vars that exist in the contract but may be intentionally blank (e.g. SMTP_PASSWORD= on a deployment that hasn't configured SMTP yet). - \$$VAR$$ — escape. The leading backslash is dropped at resolution time and the rest is emitted literally. Use this when documenting the syntax inside a string literal (comments in env-file templates, for example) where a regex scan would otherwise treat the mention as a real reference. Combines with ? as \$$?VAR$$.

  • env/update_env_variable.ts

    Write updates to .env files while preserving formatting.