npm.io
1.4.0 • Published 4 years ago

env-var-base

Licence
MIT
Version
1.4.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0
Stars
3

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

Keywords