# Config

```javascript
const config = require('config')
```

The config module serves as general purpose key/value storage for organization configuration and secrets.

Configuration keys can be exported and imported using the developer tools when *they are named using namespace rules* (c\_ or namespace\_\_) to keep local secrets out of version control. Config keys can also be included in Deployments.

{% hint style="success" %}
An organization can store around 256k of config data.
{% endhint %}

{% hint style="warning" %}
There are no access controls surrounding config data in-script.
{% endhint %}

## module Config

### keys()

Returns the list of configuration keys.

*Returns*

* { String\[] } An array of configuration keys.

### get(key)

Returns the value for a configuration key. The key can also be an object property path.

*Arguments*

* `key` { String } The key name or object property path.

*Returns*

* { \* } The key value.

### set(key, val)

Set the value for a configuration key.

*Arguments*

* `key` { String } The key name or object property path.
* `val` { \* = *null* } The value. Overwrites the value at `key`. If null, unsets the value at `key`.

*Returns*

* { \* } The key value.

## Examples

### Using get() and set()

```javascript
const should = require('should'),
      config = require('config')

// set a top-level secret
config.set('secret', {foo: 'bar'})

// set a pathed value
config.set('secret.foo', 'baz')

// set a path object
config.set('secret.cake', {eat: 'it', too: 'yes!'})

should.equal(config.get('secret.foo'), 'baz')
should.equal(config.get('secret.cake.too'), 'yes!')
```

### Using convenience methods

The config module may also be called as a function for getting and setting values.

```javascript
const config = require('config')

// set a top-level secret
config('secret', {foo: 'bar'})

// set a pathed value
config('secret.foo', 'baz')

// set a path object
config('secret.cake', {eat: 'it', too: 'yes!'})

should.equal(config('secret.foo'), 'baz')
should.equal(config('secret.cake.too'), 'yes!')
```
