8000 GitHub - jusguy/config-typed: Configuration through process.env in the spirit of TypeScript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jusguy/config-typed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

config-typed

Configuration through process.env in the spirit of TypeScript

This is a placeholder for an idea I want to build. It is the next evolution of my config-twelve module.

The problem

Street standard for Node.js configuration is using environment variables (see third factor). It is also common practice to use dotenv for development. The problem is that it is weak typed and requires lots of handling for validation. How many times have you had a issue with missing or invalid environment variables? For example:

  • process.env forces all of it's properties to be strings.
  • I use process.env.BASE_URL in my config and locally provide https://127.0.0.1:8080 but another engineer deploys to production with https://prod.com/ (notice the trailing slash). Did I write logic to account for this?
  • Dealing with truthy and falsey values can be tricky. If process.env.LOG_TRANSACTIONS === undefined is that false? What about process.env.LOG_TRANSACTIONS === 'yes'?
  • Windows env variables are case-sensitive, while in Linux the aren't
  • Forgot to setup a new environment variable when deploying

The solution

I aim for config-typed to provide a TypeScript module that:

  • Requires you to define env variables for the application (even if optional)
  • Throws fatal exception for missing (required) variables
  • Validates the variables (strictly typed)
  • Supports defaults for optional
  • Gives benefits of IDE auto complete afforded by TypeScript

About

Configuration through process.env in the spirit of TypeScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0