@hypercolor/envconfig
TypeScript icon, indicating that this package has built-in type declarations

1.0.15 • Public • Published

@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

Project Repository

Organization Repository

Package Sidebar

Install

npm i @hypercolor/envconfig

Weekly Downloads

163

Version

1.0.15

License

MIT

Unpacked Size

7.94 kB

Total Files

5

Last publish

Collaborators

  • seth_hypercolor
  • andrew-hypercolor