env-var-base
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

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

Package Sidebar

Install

npm i env-var-base

Weekly Downloads

217

Version

1.4.0

License

MIT

Unpacked Size

7.52 kB

Total Files

6

Last publish

Collaborators

  • glebbash