Skip to content

hypercolor/envconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@hypercolor/envconfig

Table of Contents

Introduction

Use decorators to pull in configuration data from environment variables or volume mounts. Use the "fail fast" principle to ensure that all required variables are present before the application starts.

Adding the @requiredEnv or @optionalEnv decorator to a variable HOST_URL will do the following:

  • If process.env.HOST_URL is defined, use that value
  • If a volume mount is present at /etc/config/env/HOST_URL, use that value
  • If a volume mount is present at /etc/config/sec/HOST_URL, use that value
  • For @requiredEnv, if none of the above are present, throw an error

Installation

  • NPM
    • npm i @hypercolor/envconfig
  • Yarn
    • yarn add @hypercolor/envconfig

Usage

import {requiredEnv} from '@hypercolor/envconfig';

export class ConfigVariables {
  @requiredEnv() public ENVIRONMENT_NAME: string;
  @requiredJsonEnv() public SOME_PRIVATE_KEY_JSON: IPrivateKeyJson;
  @optionalEnv() public DEBUG?: string;
}

More Information

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published