# @ehcan/envparser

> You can parse multiple types for your environment variables.

Latest version **1.0.3** (published 2021-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ehcan/envparser
pnpm add @ehcan/envparser
yarn add @ehcan/envparser
bun add @ehcan/envparser
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-03-15 |
| First published | 2021-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | seyedi_es@icloud.com |
| Maintainers | ehcan |
| Keywords | env |

## Links

- npm: https://www.npmjs.com/package/@ehcan/envparser
- Repository: https://github.com/Ehcaning/envparser
- Homepage: https://github.com/Ehcaning/envparser#readme
- Issues: https://github.com/Ehcaning/envparser/issues
- npm.io page: https://npm.io/package/@ehcan/envparser

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-03-15
- 1.0.2 — 2021-03-15
- 1.0.1 — 2021-03-15
- 1.0.0 — 2021-03-15

## README

# Env Parser

A simple module for parse env variables into required type.

Example:

```js
const env = require('@ehcan/envparser');

config = {
	db: {
		host: env.str('DB_HOST', 'localhost'),
		port: env.num('DB_PORT', 5432),
		username: env.str('DB_USER', 'user_1'),
		password: env.str('DB_PASS', 'passwd'),
		queryLog: env.bool('DB_QUERY_LOG', true),
		options: env.array('DB_OPTIONS', ['option_1', 'option_2']),
	},
};

console.log(config);
```
Without `env` file:
```json
console.log(config);

{
  "db": {
    "host": "localhost",
    "port": 5432,
    "username": "user_1",
    "password": "passwd",
    "queryLog": true,
    "options": [
      "option_1",
      "option_2"
    ]
  }
}
```

With `env` file:
```env
DB_HOST=pg
DB_PORT=5400
DB_USER=my_user
DB_PASS=my_pass
DB_QUERY_LOG=false
DB_OPTIONS=option_3,option_4
```

```json
console.log(config);

{
  "db": {
    "host": "pg",
    "port": 5400,
    "username": "my_user",
    "password": "my_pass",
    "queryLog": false,
    "options": [
      "option_3",
      "option_4"
    ]
  }
}
```

---
_Source: https://npm.io/package/@ehcan/envparser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
