# config

[![pipeline status](https://it-devops-01.br-edv.brnet.int/general/config/badges/master/pipeline.svg)](https://it-devops-01.br-edv.brnet.int/general/config/commits/master)
[![coverage report](https://it-devops-01.br-edv.brnet.int/general/config/badges/master/coverage.svg)](https://it-devops-01.br-edv.brnet.int/general/config/commits/master)
[![Quality Gate Status](https://it-devops-01.br-edv.brnet.int:8999/api/project_badges/measure?project=config&metric=alert_status)](https://it-devops-01.br-edv.brnet.int:8999/dashboard?id=config)

Simple Config Log with HashiCorp Vault support.

## Installation

- `npm config set @br:registry https://npm.br-edv.brnet.int`
- `npm config set strict-ssl false`
- `npm install --save @br/config`

## Usage

`const Config = require('@br/config')`  
`let config = new Config()`

Then config is your config object. (Use it like config.setting)

It reads from the following sources, performing a deep merge:  
(The Top Value overwrites the lower ones)

- ENV
- config.json
- config.defaults.json

Enviroment Variables can target deep nested settings:  
The Setting _setting.deep.key_ can be reached with *SETTING_DEEP_KEY*

## Examples

### Only config.defaults.json

`node examples/only-defaults/index.js`

### Only config.json

(Kind of legacy use)

`node examples/only-local/index.js`

### defaults and config.json

`node examples/defaults-overwrite/index.js`

### enviroment variables

(Enviroment set by command to not pollute your machine)

`SETTING=overwritten-by-env node examples/env/index.js`