# deep-conf

> node.js configuration libruary

Latest version **0.1.6** (published 2017-01-27) · 0 weekly downloads

## Install

```sh
npm install deep-conf
pnpm add deep-conf
yarn add deep-conf
bun add deep-conf
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2017-01-27 |
| First published | 2014-01-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Artem Zhukov |
| Maintainers | 2do2go |
| Keywords | deep-conf, deep, conf, config, configuration, builder, settings, env, environment |

## Links

- npm: https://www.npmjs.com/package/deep-conf
- Repository: https://github.com/2do2go/deep-conf
- Homepage: https://github.com/2do2go/deep-conf#readme
- Issues: https://github.com/2do2go/deep-conf/issues
- npm.io page: https://npm.io/package/deep-conf

## 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

- 0.1.6 (latest) — 2017-01-27
- 0.1.5 — 2017-01-27
- 0.1.4 — 2017-01-19
- 0.1.3 — 2015-10-29
- 0.1.2 — 2015-05-22
- 0.1.1 — 2014-12-08
- 0.1.0 — 2014-12-08
- 0.0.7 — 2014-12-08
- 0.0.6 — 2014-09-25
- 0.0.5 — 2014-06-11
- 0.0.4 — 2014-06-10
- 0.0.3 — 2014-01-31
- 0.0.2 — 2014-01-27
- 0.0.1 — 2014-01-27

## README

# Deep-conf

Configuration library for Node.js application server deployments.
It lets you define a set of configs with inheritance.

## Quick Start

Install it with NPM or add it to your package.json:

```js
$ npm install deep-conf
```

Then:

```js
// Create instance by factory
var configBuilder = require('deep-conf')();

// Register new config with name "sampleConfig"
configBuilder.register({
	name: 'sampleConfig',
	config: {
		host: 'localhost',
		port: 80,
		fullName: function(config) {
			return 'http://' + config.host + ':' + config.port;
		}
	}
});

// Get registered config by name
var config = configBuilder.get('sampleConfig');

console.log(config.host, config.port, config.fullName);
// localhost 80 http://localhost:80
```

## API

**register**: create new config with name and optional parent. NOTE: field __info__, 
that contains name and parentName, will be added to config, so do not add to your
config field with this name, because it will be overrided.

```js
// Register new config with name "development"
configBuilder.register({
	name: 'development',
	config: {
		host: 'localhost',
		port: 80
	}
});

// Register new config with name "production",
// inherite it from "development"
// and replace field "host" with new value
configBuilder.register({
	name: 'production',
	parent: 'development',
	config: {
		host: 'example.com'
	}
});
```

**update**: update existing config

```js
// Update fields of existing config "development"
configBuilder.update({
	name: 'development',
	config: {
		protocol: 'https'
	}
});
```

**get**: get registered config

```js
// Get config "production"
var config = configBuilder.get('production');

console.log(config.host, config.port);
// example.com 80
```

**func**: define in config functional field

```js
// Register config with functional field
configBuilder.register({
	name: 'funcConfig',
	config: {
		f: configBuilder.func(function(a, b) {
			return a + b;
		})
	}
});

var config = configBuilder.get('funcConfig');

console.log(config.f(1, 2));
// 3
```

**stringify**: get registered config as string with optional space count (like JSON.stringify)

```js
// Register config "stringConfig"
configBuilder.register({
	name: 'stringConfig',
	config: {
		host: 'localhost',
		port: 80,
		fullName: function(config) {
			return 'http://' + config.host + ':' + config.port;
		},
		sum: configBuilder.func(function(a, b) {
			var sum = a + b;
			return sum;
		})
	}
});

// Stringify config "stringConfig"
var str = configBuilder.stringify('stringConfig', 2);

console.log(str);
// {
//   "host": "localhost",
//   "port": 80,
//   "fullName": "http://localhost:80",
//   "sum": function (a, b) {var sum = a + b;return sum;}
// }
```

**ConfigBuilder**: create instance with constructor

```js
var configBuilder = new (require('deep-conf').ConfigBuilder)();
```

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