[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
49
README.md
49
README.md
|
@ -216,7 +216,9 @@ Loads a given object literal into the configuration hierarchy. Both `nconf.defau
|
|||
```
|
||||
|
||||
### 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
|
||||
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.
|
||||
|
||||
#### 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
|
||||
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
|
||||
|
||||
### Installing npm (node package manager)
|
||||
```
|
||||
curl http://npmjs.org/install.sh | sh
|
||||
```
|
||||
|
||||
### 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
|
||||
npm install nconf --save
|
||||
```
|
||||
|
||||
## Run Tests
|
||||
|
|
|
@ -8,8 +8,12 @@
|
|||
var fs = require('fs'),
|
||||
async = require('async'),
|
||||
common = require('./nconf/common'),
|
||||
Provider = require('./nconf/provider').Provider,
|
||||
nconf = module.exports = new Provider();
|
||||
Provider = require('./nconf/provider').Provider;
|
||||
|
||||
//
|
||||
// `nconf` is by default an instance of `nconf.Provider`.
|
||||
//
|
||||
var nconf = module.exports = new Provider();
|
||||
|
||||
//
|
||||
// Expose the version from the package.json
|
||||
|
|
Loading…
Reference in a new issue