# config-from-env

> Simple lib to load environment vars into your config

Latest version **1.0.1** (published 2014-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install config-from-env
pnpm add config-from-env
yarn add config-from-env
bun add config-from-env
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-12-09 |
| First published | 2014-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dallin Osmun |
| Maintainers | numso |

## Links

- npm: https://www.npmjs.com/package/config-from-env
- Repository: https://github.com/KualiCo/config-from-env
- Issues: https://github.com/KualiCo/config-from-env/issues
- npm.io page: https://npm.io/package/config-from-env

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1

## Recent versions

- 1.0.1 (latest) — 2014-12-09
- 1.0.0 — 2014-12-09

## README

kc-env-config
=============

A simple module to load your config from the environment. You pass in a valid config object full of all your defaults. It will traverses over that object and replaces the default values with values from the environment if they exist. It's called recursively on nested objects. Only supports numbers, strings, and booleans for data.

###Install

`npm i --save env-config`

###Usage

`var config = load(defaults, environment, prefix, loose)`

 - `defaults`: required. Your config object. Can contain numbers, strings, booleans, and more nested objects.
 - `environment`: required. Usually just `process.env`
 - `prefix`: optional. default=''. The key prefix on your environment.
 - `loose`: optional. default=false. If a matching key exists on the environment, use it no matter the type (will end up as a string). (default: only use environment variables when the key matches AND the type is the same. Type is saved)

###Example

Environment Variables:
```bash
export PROJECT_PORT=4545
export PROJECT_DB_HOST=192.168.1.5
```

Code:
```javascript
var load = require('kc-env-config');

var defaults = {
  port: 3000,
  db: {
    host: 'localhost',
    port: 28015
  }
};

var config = load(defaults, process.env, 'PROJECT');
console.log(config);
```

Outputted Config:
```json
{
  "port": 4545,
  "db": {
    "host": "192.168.1.5",
    "port": 28015
  }
}
```

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