Skip to content
New issue

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

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

Already on GitHub? # to your account

Adding conventions for loading environment variables? #77

Open
emilos opened this issue Mar 13, 2020 · 3 comments
Open

Adding conventions for loading environment variables? #77

emilos opened this issue Mar 13, 2020 · 3 comments

Comments

@emilos
Copy link

emilos commented Mar 13, 2020

A common issue with deploying the app is ensuring that everything works. Sometimes you end up seeing that something is not working due to misconfiguration/ missing env variables.

Some time ago I wrote this: https://github.com/buxlabs/envb to make it a bit easier to control env variables.

It has a simple API:

  • env.fetch('SOME_ENV_VAR') throws if the variable is missing
  • env.get('SOME_ENV_VAR') does not throw

There are probably better libs, just wanted to highlight the idea.

@zaiste
Copy link
Collaborator

zaiste commented Mar 13, 2020

@emilos I like this idea! In which scenerios you would use the method that does not throw? Maybe we should force throwing, so it's explicit and easier to discover for users ?

@emilos
Copy link
Author

emilos commented Mar 13, 2020

Some environment variables are not necessary for the app to work, e.g. env.get('SESSION_TIMEOUT') || 10.

Some are, e.g. env.fetch('EXTERNAL_SERVICE_URL').

It might make sense to always require them, not sure what's the right balance here.

@FDiskas
Copy link

FDiskas commented Jan 6, 2021

I would suggest https://github.com/motdotla/dotenv
it is way more popular and extendable. create react app and other are using it

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants