Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Expand config values with env variables #14

Merged
merged 7 commits into from
Mar 24, 2022
Merged

Conversation

zoran995
Copy link
Owner

@zoran995 zoran995 commented Feb 26, 2022

Create a possibility to move API keys & Auth keys out of server config
and store them in environment variables. This should also allow storing
credentials in storage designed for credentials (i.e. deployment
secrets).

Loading of environment values is done using dotenv package, and those values are further expanded using dotenv-expand. Loaded environment variables are then used for expanding values loaded from json config. Expansion is done the same way as with dotenv-expand, meaning expansion will follow rules:

  • $KEY will expand any env with the name KEY
  • ${KEY} will expand any env with the name KEY
  • $KEY will escape the $KEY rather than expand
  • ${KEY:-default} will first attempt to expand any env with the name KEY. If not found, then it will return default

Three new cli config options are added

  • ignore-env-file - do not load values from .env file
  • ignore-env-vars - do not load values from process.env
  • env-file-path - path to env file (default .env)

Env vars and env values are currently not used so skip them when
initializing nest config module. Follow up commits will add support for
interpolating config values using env values.
Create a possibility to move API keys & Auth keys out of server config
and store them in environment variables. This should also allow storing
credentials in storages designed for credentials (i.e. deployment
secrets).

Loading of environment is done using `dotenv` package, and those values
are further expanded using `dotenv-expand`. Loaded environment variables
are then used for expanding values loaded from json config. Expansion is
done the same way as with `dotenv-expand`.

Three new cli config options are added
- ignore-env-file - do not load values from .env file
- ignore-env-vars - do not load values from process.env
- env-file-path - path to env file (default .env)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant