Environment variables

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 2

  • @VarunDeva23
    @VarunDeva23 Рік тому

    This is very good way to get all the env values to one place and exporting from there
    One thing i request you add validation for it
    Before running application it should check all the values are available or not if its not available application should not run
    I tried some ways but typescript gives error
    I mentioned type for secret.ts file
    Made an object which contains all the values and exporting that object
    To access the port i use config.port, config.db_user etc
    Which is the proper production ready way?

    • @evoqys
      @evoqys  Рік тому

      You can write your own validations for env variables, which is considered as best practise to avoid any runtime errors. How ever some frameworks provides this feature out of box like AdonisJS
      docs.adonisjs.com/guides/environment-variables#validating-environment-variables
      You can have a look at above link and can do something similar in raw nodejs as well.