# service-cloud-config

> nodejs cloud service config

Latest version **0.1.6** (published 2016-08-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install service-cloud-config
pnpm add service-cloud-config
yarn add service-cloud-config
bun add service-cloud-config
```

## 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 | 2016-08-04 |
| First published | 2016-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Andre Pinto |
| Maintainers | andrepinto |
| Keywords | nodejs, cloud, config, consul |

## Links

- npm: https://www.npmjs.com/package/service-cloud-config
- Repository: https://github.com/andrepinto/service-cloud-config
- Homepage: https://github.com/andrepinto/service-cloud-config#readme
- Issues: https://github.com/andrepinto/service-cloud-config/issues
- npm.io page: https://npm.io/package/service-cloud-config

## Dependencies (3)

- [consul](https://npm.io/package/consul.md) ^0.23.0
- [lodash](https://npm.io/package/lodash.md) ^4.1.0
- [doc-path](https://npm.io/package/doc-path.md) ^1.0.7

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

- 0.1.6 (latest) — 2016-08-04
- 0.1.4 — 2016-02-01
- 0.1.2 — 2016-02-01
- 0.1.0 — 2016-01-31
- 0.0.3 — 2016-01-27
- 0.0.2 — 2016-01-27
- 0.0.1 — 2016-01-26

## README

About service-cloud-config
===================

**service-cloud-config** is a nodejs module that provides client-side support for externalized configuration in a distributed system.

---------------

Adpters
-------------
currently only supports:
 **Consul** 
 
![enter image description here](http://tfitch.com/automation-tools-bootcamp/images/consul-mini-logo.png)

Installation
-------------

    $ npm install service-cloud-config


Overview
-------------
service-cloud-configr used the service name to discovery the settings


**service-cloud-config Options**
----------

 - **service** - Module name. Default **null**
 - **adapter** - Used adpter. Default **null**
 - **store** - save service config local. Default **true**
 - **mergeWithConfigEnv** - If this option is enabled then the module settings will inherit the module *envServiceName*. Default **true**
 - **envServiceName** - The parent module name: Default **environment**


Inheritance
-----------
If **mergeWithConfigEnv = true** then

example:

    environment config = {
		database:{
			ip:"127.0.0.1",
			port:8091
		},
		elasticsearch:{
			ip:"127.0.0.1",
			port:9200
		}
	}

	my-module config = {
		elasticsearch:{
			ip:"192.168.99.100",
			port:9202
		},
		amqp:{
			host:"127.0.0.1"
		}
	}

	result config = {
		database:{
			ip:"127.0.0.1",
			port:8091
		},
		elasticsearch:{
			ip:"192.168.99.100",
			port:9202
		},
		amqp:{
			host:"127.0.0.1"
		}
	}

API
-------------

 - **start(callback)** - start adpater connection
 - **getData(options, callback)** - get all configurations remotely
 -  **get(key)** - get config value locally. Only works if **store = true**
 - **getRemoteValue(key, callback)** - get single config key remotely


**Consul**
------
> **Note:**

> - The consul adapter uses kv to store configurations

    adapter:{
        name:'consul',
        connection:{
            host: '192.168.99.100',
            port: 8500
        }
    },

Usage
-------------

**Consul kv**

my-service/database/ip

```javascript
    var ServiceCloudConfig = require('service-cloud-config');
    
    
    var config = new ServiceCloudConfig({
        service:'my-service',
        adapter:{
            name:'consul',
            connection:{
                host: '192.168.99.100',
                port: 8500
            }
        },
        mergeWithConfigEnv:true
    });
    
    
    config.start( function(err, data){
        config.getData(function(err, data){
           console.log(data);
        });
    });

```

 - **get configurations (locally)**
		
	 - take paths in documents which can include nested paths specified by '.'s and can evaluate the path to a value


 ```javascript
    config.get('database.ip');
  ```

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