Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glebbash/env-var-base
Class based configuration for env-var
https://github.com/glebbash/env-var-base
environment-variables hacktoberfest typescript
Last synced: about 2 months ago
JSON representation
Class based configuration for env-var
- Host: GitHub
- URL: https://github.com/glebbash/env-var-base
- Owner: glebbash
- License: mit
- Created: 2021-03-03T07:38:55.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T19:25:13.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T16:49:20.563Z (about 2 months ago)
- Topics: environment-variables, hacktoberfest, typescript
- Language: TypeScript
- Homepage: https://glebbash.github.io/env-var-base
- Size: 966 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# env-var-base
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Coverage Status](https://coveralls.io/repos/github/glebbash/env-var-base/badge.svg?branch=master)](https://coveralls.io/github/glebbash/env-var-base?branch=master)Base configuration class that uses
[env-var](https://github.com/evanshortiss/env-var)
and
[dotenv](https://github.com/motdotla/dotenv)Installation:
```sh
npm i env-var-base
```Usage:
```ts
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:
```ts
type Env = { PORT: string, HOST: string }class AppConfig extends BaseConfig {}
```or directly:
```ts
class AppConfig extends BaseConfig<'PORT' | 'HOST'> {}
```Bootstrapped with