env-var-base
v1.4.0
Published
Base configuration class that uses env-var and dotenv
Downloads
1,149
Maintainers
Readme
env-var-base
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