# @ecocea/config-loader

> NPM Module for Environment Config Load

Latest version **1.0.2** (published 2018-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ecocea/config-loader
pnpm add @ecocea/config-loader
yarn add @ecocea/config-loader
bun add @ecocea/config-loader
```

## 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.2 |
| Published | 2018-11-02 |
| First published | 2017-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Thibault Brocheton |
| Maintainers | zangdar |
| Keywords | config, environment |

## Links

- npm: https://www.npmjs.com/package/@ecocea/config-loader
- Repository: https://github.com/ecocea/config-loader
- Homepage: https://github.com/ecocea/config-loader#readme
- Issues: https://github.com/ecocea/config-loader/issues
- npm.io page: https://npm.io/package/@ecocea/config-loader

## Dependencies (1)

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

## 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) — 2018-11-02
- 1.0.1 — 2018-03-12
- 1.0.0 — 2018-02-09
- 0.1.2 — 2017-11-24
- 0.1.1 — 2017-11-24
- 0.1.0 — 2017-11-24
- 0.0.1 — 2017-11-17

## README

# @ecocea/config-loader
NPM Module for Environment Config Load  

Use a default configuration file, and overwrite it with an environment specific configuration file.  
This use Lodash _.mergeWith() function, however arrays are not merged but replaced.

### Prerequisites
Tested on Node.js 8+  
Requires ES6 compatibility

### Installation
```sh
npm install @ecocea/config-loader --save
```

### Initialisation
```javascript
//Path of the directory containing global and environments configurations
const configPath = path.join(__dirname, './config');
  
//Environment config that should be loaded
const env = process.env.environment;
  
//Retrieve the merge configuration of global and specified environment
const config = require('@ecocea/config-loader')(configPath, env);
```

### Other calls
```javascript
const config = require('@ecocea/config-loader');
```

### Config load and Customization
The script expect a file named config.js in the configPath, and every environment config file should be named config_{env}.js
You can customize the configuration file name, and the separator between filename and environment:
```javascript
//Mandatory
const configPath = path.join(__dirname, './config');
const env = process.env.environment;
  
//Optionnal
const configName = "properties";
const configSeparator = "-";
  
//First call
const config = require('@ecocea/config-loader')(configPath, env, configName, configSeparator);
```

### Tips for Heroku
Avoid using too much Heroku Config Vars. If you want the ability to quickly override a config var without deploying, you can do:
```javascript
const myConfigVar = process.env.MY_CONFIG_VAR || 'ThisIsMyConfigVar';
```

### Migrating from 0.x.x to 1.x.x
At first call, remove the init method  
For other calls, remove all .getConfig()

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