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

refactor!: environment variables validation #216

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Commits on Nov 21, 2023

  1. refactor!: environment variables validation

    Refactor environment variable validation rules. Apply consistent
    patterns to env validation.
    
    The main motivation for this change was as follows:
    
    1. Make env validation more strict and consistent. Stick to the same
    validation patterns in different projects.
    
    2. Provide consistent fallback options for optional variables.
    
    Here are the main changes:
    
    1. Previously if a user set an empty string as the variable name in the
    .env file like this: ``` VARIABLE_NAME= ``` not all variable
    initializers assigned a correct default value to the variable in this
    case. Now it is fixed. For the purpose of this improvement, now all
    optional variable initializers always have the `@Transform` decorator
    that provides a default value for the variable. Also for this purpose,
    the `toBoolean` function has been refactored to be more similar to the
    `toNumber` function.
    
    2. Make validation of boolean variables more strict. CAUTION: This might
    be a breaking change for users who use values like "yes" to initialize
    boolean variables.
    
    3. Implement the new `toArrayOfUrls()` function to provide a reasonable
    default value for variables that should have a list of URLs in their
    values. This function also fixes a bug with default values for such
    variables. Previously, if a user set an empty string as a value of such
    variables, the validation worked incorrectly.
    
    4. Now we validate that values in `PROVIDERS_URLS` and `CL_API_URLS` are
    indeed URLs.
    
    5. The `CHAIN_ID` variable now supports only a pre-defined list of
    testnet IDs. Add the appropriate `Network` enum for this purpose.
    CAUTION: Currently the Keys API doesn't officially support testnets
    other than Goerli, Holesky, and Mainnet. But this might be a breaking
    change if some users use Keys API for other testnets.
    
    6. More strict validation for the `PORT` and `DB_PORT` values. CAUTION:
    This might be a breaking change.
    
    7. Add the `@IsNotEmpty` decorator to the required variables.
    
    8. Fix confusing validation rules for the `DB_PASSWORD` variable. Add
    default value.
    AlexanderLukin committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    3a407f3 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2023

  1. refactor!: environment variables validation

    Resolve review comments. The main changes are:
    
    1. Loosen validation rules for boolean variables. Now numbers "1" and
    "0" and constants "yes" and "no" are accepted as valid boolean values.
    
    2. Make DB password value required. Remove the default empty DB password
    value.
    
    3. Rename the `Network` interface to `Chain`.
    AlexanderLukin committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    6b59254 View commit details
    Browse the repository at this point in the history