[doc minor] Update docs for secure information.
This commit is contained in:
parent
0358545ae5
commit
9dbed2d2cd
2 changed files with 41 additions and 20 deletions
53
README.md
53
README.md
|
@ -20,8 +20,8 @@ Using nconf is easy; it is designed to be a simple key-value store with support
|
||||||
// 3. A file located at 'path/to/config.json'
|
// 3. A file located at 'path/to/config.json'
|
||||||
//
|
//
|
||||||
nconf.argv()
|
nconf.argv()
|
||||||
.env()
|
.env()
|
||||||
.file({ file: 'path/to/config.json' });
|
.file({ file: 'path/to/config.json' });
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set a few variables on `nconf`.
|
// Set a few variables on `nconf`.
|
||||||
|
@ -216,7 +216,9 @@ Loads a given object literal into the configuration hierarchy. Both `nconf.defau
|
||||||
```
|
```
|
||||||
|
|
||||||
### File
|
### File
|
||||||
Based on the Memory store, but provides additional methods `.save()` and `.load()` which allow you to read your configuration to and from file. As with the Memory store, all method calls are synchronous with the exception of `.save()` and `.load()` which take callback functions. It is important to note that setting keys in the File engine will not be persisted to disk until a call to `.save()` is made. Note a custom key must be supplied as the first parameter for hierarchy to work if multiple files are used.
|
Based on the Memory store, but provides additional methods `.save()` and `.load()` which allow you to read your configuration to and from file. As with the Memory store, all method calls are synchronous with the exception of `.save()` and `.load()` which take callback functions.
|
||||||
|
|
||||||
|
It is important to note that setting keys in the File engine will not be persisted to disk until a call to `.save()` is made. Note a custom key must be supplied as the first parameter for hierarchy to work if multiple files are used.
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
nconf.file('path/to/your/config.json');
|
nconf.file('path/to/your/config.json');
|
||||||
|
@ -229,6 +231,35 @@ The file store is also extensible for multiple file formats, defaulting to `JSON
|
||||||
|
|
||||||
If the file does not exist at the provided path, the store will simply be empty.
|
If the file does not exist at the provided path, the store will simply be empty.
|
||||||
|
|
||||||
|
#### Encrypting file contents
|
||||||
|
|
||||||
|
As of `nconf@0.8.0` it is now possible to encrypt and decrypt file contents using the `secure` option:
|
||||||
|
|
||||||
|
``` js
|
||||||
|
nconf.file('secure-file', {
|
||||||
|
file: 'path/to/secure-file.json',
|
||||||
|
secure: {
|
||||||
|
secret: 'super-secretzzz-keyzz',
|
||||||
|
alg: 'aes-256-ctr'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
This will encrypt each key using [`crypto.createCipher`](https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password), defaulting to `aes-256-ctr`. The encrypted file contents will look like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"config-key-name": {
|
||||||
|
"alg": "aes-256-ctr", // cipher used
|
||||||
|
"value": "af07fbcf" // encrypted contents
|
||||||
|
},
|
||||||
|
"another-config-key": {
|
||||||
|
"alg": "aes-256-ctr", // cipher used
|
||||||
|
"value": "e310f6d94f13" // encrypted contents
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Redis
|
### Redis
|
||||||
There is a separate Redis-based store available through [nconf-redis][0]. To install and use this store simply:
|
There is a separate Redis-based store available through [nconf-redis][0]. To install and use this store simply:
|
||||||
|
|
||||||
|
@ -252,22 +283,8 @@ Once installing both `nconf` and `nconf-redis`, you must require both modules to
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Installing npm (node package manager)
|
|
||||||
```
|
```
|
||||||
curl http://npmjs.org/install.sh | sh
|
npm install nconf --save
|
||||||
```
|
|
||||||
|
|
||||||
### Installing nconf
|
|
||||||
```
|
|
||||||
[sudo] npm install nconf
|
|
||||||
```
|
|
||||||
|
|
||||||
## More Documentation
|
|
||||||
There is more documentation available through docco. I haven't gotten around to making a gh-pages branch so in the meantime if you clone the repository you can view the docs:
|
|
||||||
|
|
||||||
```
|
|
||||||
open docs/nconf.html
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run Tests
|
## Run Tests
|
||||||
|
|
|
@ -8,8 +8,12 @@
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
common = require('./nconf/common'),
|
common = require('./nconf/common'),
|
||||||
Provider = require('./nconf/provider').Provider,
|
Provider = require('./nconf/provider').Provider;
|
||||||
nconf = module.exports = new Provider();
|
|
||||||
|
//
|
||||||
|
// `nconf` is by default an instance of `nconf.Provider`.
|
||||||
|
//
|
||||||
|
var nconf = module.exports = new Provider();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Expose the version from the package.json
|
// Expose the version from the package.json
|
||||||
|
|
Loading…
Reference in a new issue