# env-dyn-config

> Dynamic config files depending on env

Latest version **1.0.2** (published 2022-07-20) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-07-20 |
| First published | 2022-07-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nick Fielton |
| Maintainers | nickfielton |
| Keywords | dyn, dynamic, conf, config, configuration |

## Links

- npm: https://www.npmjs.com/package/env-dyn-config
- Repository: https://github.com/NickFielton/env-dyn-config
- Homepage: https://github.com/NickFielton/env-dyn-config#readme
- Issues: https://github.com/NickFielton/env-dyn-config/issues
- npm.io page: https://npm.io/package/env-dyn-config

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-07-20
- 1.0.1 — 2022-07-20
- 1.0.0 — 2022-07-20

## README

# env-dyn-config

env-dyn-config is simple approach for **dynamic configuration** files.
It breaks down the configuration depending on the **environment** distinguiting the **base** from the env's **specifics**.

## Install

Recommended to install locally

``` bash
npm install env-dyn-config --save
```

Or installing with yarn? `yarn add env-dyn-config`

## Usage

### 1. Environment

Since this uses the [dotenv](https://www.npmjs.com/package/dotenv) package, create a `.env` file in the root of your project:

``` .env
NODE_ENV="development"
```

### 2. env-dyn-config intialization

Add the following file to initialize the module.

``` ts
/// env-dyn-config.config.ts
import init from "env-dyn-config";

export default init();
```

### 3. Your first config

Add your config file.

``` ts
/// config.ts
import edc from "./env-dyn-config.config";
const { combine, environments } = edc;

const specific = {
    [environments.production]: {
        property: "for your dear clients"
    }
}

export default combine({
    property: "for devs only"
}, specific);
```

NB: as early as possible in your application, import / configure env-dyn-config. Once imported, the returned value of each exported combine remains the same (since its cached).

For more **examples** see repo [env-dyn-config-examples](https://github.com/NickFielton/env-dyn-config-examples.git)

## Documentation

This package exposes a function, once runned, returning:

- `environments` the list of environment names
- `ENV` the current environment recognized by dotenv
- `fusion` a method to merge configurations

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