Options
All
  • Public
  • Public/Protected
  • All
Menu

env-var-base

env-var-base

styled with prettier Coverage Status

Base configuration class that uses env-var and dotenv

Installation:

npm i env-var-base

Usage:

class AppConfig extends BaseConfig {
port = this.get('PORT').default(3000).asPortNumber()
}
const config = new AppConfig()
console.log(config.port) // 3000

Env names can also be typed like this:

type Env = { PORT: string, HOST: string }

class AppConfig extends BaseConfig<keyof Env> {}

or directly:

class AppConfig extends BaseConfig<'PORT' | 'HOST'> {}

Bootstrapped with https://github.com/LuisReinoso/typescript-library-starter

Generated using TypeDoc