EnvOne — Formalize your Node.js application environment variables

It is a zero-dependency module that loads dynamic environment configurations from a .env.config file, and process it as environment variables into process.env

Are there any applications running without depending on environment variables? I don’t think so — Environment based configurations are an essential requirement when you deal with one or more environments.

How many environments do you have right now for your application? Usually, most of us will have a development environment, staging environment, and production environment. So you have to have the same or different environment variables separately for these environments. Usually, we use different sets of credentials, URLs, and other secrets to the production environment.

Let me discuss more about Node.js applications here, So how do you pass environment variables to your Node.js application?

  • Start your application by passing the environment variables directly
  • Use any helper package to load the environment variables from any configurations. e.g: dotEnv

Here, the main question is How do you manage your environment variables across multiple developers separately for each environment?

  • Document it on a common page, and ask your developer to refer that page for the required environment.
  • Use different environment files(.env) for different environments and share it among your developers.
  • Use the cloud-based environment variable providers(AWS/GCP) or CI/CD based helper applications
dotEnv based environment variable management

We usually commit our application source code to version control, but we can’t commit our environment files(.env) to version control as it’s a mix of secrets and keys.

When you check your environment variables, actually not all of those are secretes — So we feel that it’s great to separate those secrets, and commit other environment variables to version control (e.g: URLs, usernames, numeric values, and other non-secrets).

Play with EnvOne!

EnvOne is providing an awesome feature to extract your non-secrets to a universal configuration file (.env.config), which helps to keep all your environment-related configurations in a single place.

Not only this, but these are also the features of EnvOne,

  • Using the dynamic configuration feature, reduce your amount of configurations in .env.config file.
  • Commit your .env.config to your source control. So you can keep track of any changes and manage it easily with your source code.

Here, how to separate secrets and non-secrets using EnvOne?

  • Just skip the secrets from .env.config, and pass it to the application like the way that you follow now.
  • Separate the secrets, and keep the low levels in .env.config file. In this example, when you start your PROD application, you have to pass ACCESS_TOKEN — You don’t have to pass anything for other environments as it will pick from DEFAULT
EnvOne and dotEnv based environment variable management

How do you feel about EnvOne now? If you feel like, it will help you to improve your development quality — Give a try by adding it to your Node.js application,

Check this following example also,

Software Engineer @ Sysco Labs, Google Summer of Code Intern @ OpenMRS