# vault-config

> an insanely simple way to back your apps config by vault

Latest version **0.0.23** (published 2019-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install vault-config
pnpm add vault-config
yarn add vault-config
bun add vault-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.0.23 |
| Published | 2019-09-03 |
| First published | 2016-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 38.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Chad Scira |
| Maintainers | icodeforlove |

## Links

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

## Dependencies (9)

- [atmpt](https://npm.io/package/atmpt.md) 1.0.3
- [debug](https://npm.io/package/debug.md) 4.1.1
- [deasync](https://npm.io/package/deasync.md) 0.1.15
- [vault-get](https://npm.io/package/vault-get.md) 0.0.12
- [fs-promise](https://npm.io/package/fs-promise.md) 2.0.3
- [node-vault](https://npm.io/package/node-vault.md) 0.9.0
- [deep-extend](https://npm.io/package/deep-extend.md) 0.6.0
- [app-root-path](https://npm.io/package/app-root-path.md) 2.2.1
- [babel-runtime](https://npm.io/package/babel-runtime.md) 6.11.6

## Recent versions

- 0.0.23 (latest) — 2019-09-03
- 0.0.22 — 2018-08-20
- 0.0.21 — 2018-08-20
- 0.0.20 — 2018-08-17
- 0.0.19 — 2018-05-08
- 0.0.18 — 2018-05-08
- 0.0.17 — 2018-01-16
- 0.0.16 — 2017-03-24
- 0.0.15 — 2017-02-28
- 0.0.14 — 2017-02-28
- 0.0.13 — 2017-02-28
- 0.0.12 — 2017-02-26
- 0.0.11 — 2016-09-28
- 0.0.10 — 2016-09-24
- 0.0.9 — 2016-09-05
- … 9 more at https://npm.io/package/vault-config/versions

## README

# vault-config

an insanely simple way to back your apps config by vault, and make it committable

[node-config](https://github.com/lorenwest/node-config) inspired config that is backed by hashicorp vault that is backed by [vault-get](https://github.com/icodeforlove/vault-get) data interface

![image](https://img42.com/grqHE+)

## install

```bash
npm install vault-config
```

## usage

setup your `.vaultrc` (you can commit this to your repo)

```javascript
{
	"VAULT_CONFIG_ENDPOINT": "...", // or use env var (required)
	"VAULT_CONFIG_ROOT_PATH": "...", // or use env var (default "secret")
	"VAULT_CONFIG_SECRET_SHARES": "...", // or use env var (default 1)

	"NODE_ENV=.*": { // default config (every other match extends this)
		"vault": { // vault-get interface
			"database": {
				"host": "website.com/databases/mysql/master/host",
				"username": "website.com/databases/mysql/master/username",
				"password": "website.com/databases/mysql/master/password"
			}
		}
	},

	"NODE_ENV=development": {
		"local": { // local temp overrides
			"database": {
				"host": "localhost",
				"username": "root",
				"password": ""
			}
		}
	},

	"NODE_ENV=production": {
		"vault": { // vault-get interface
			"gmail": {
				"username": "prod.website.com/accounts/gmail/username",
				"password": "prod.website.com/accounts/gmail/password"
			}
		}
	}
}
```

setup your `.vaultsecrets` (do not commit to repo)

```javascript
{
	"VAULT_CONFIG_TOKEN": "...", // or use env var (required)
	"VAULT_CONFIG_KEYS": ["...", "..."], // or use env var (optional)
	"VAULT_CONFIG_KEY": "..." // or use env var (optional)
}
```

if everything is correct you should be able to do the following

```javascript
// blocks on first module load if vault keys are requested
import config from 'vault-config';

console.log(config);
```

which would log out the following

```javascript
// in development
{
	database: {
		host: 'localhost',
		username: 'root',
		password: ''
	}
}

// in production
{
	database: {
		host: 'VAULE OBTAINED FROM VAULT',
		username: 'VAULE OBTAINED FROM VAULT',
		password: 'VAULE OBTAINED FROM VAULT'
	},
	gmail: {
		username: 'VAULE OBTAINED FROM VAULT',
		password: 'VAULE OBTAINED FROM VAULT'
	}
}
```

You can also specify the location of the `.vaultrc` / `.vaultsecret` files via env variables

```
VAULT_CONFIG_RCPATH=/path/to/.vaultrc
VAULT_CONFIG_SECRETSPATH=/path/to/.vaultsecret
```

## autorenew (token renewal)

by default tokens will be autorenewed you can disable this by specifying `VAULT_AUTORENEW_DISABLED=1`, and you can override the increment by doing `VAULT_AUTORENEW_INCREMENT=86400`

## localoverrides

you can create a `.vaultlocalrc` next to your `.vaultrc` and it will merge into `.vaultrc` (a `.vaultlocalrc` is not intended to be commited)

## debugging

```javascript
DEBUG=vault ...
```

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