4 changed files with 92 additions and 1 deletions
@ -0,0 +1,3 @@ |
|||
.DS_Store |
|||
config.json |
|||
test/fixtures/store.json |
@ -0,0 +1,62 @@ |
|||
# nconf |
|||
|
|||
A hybrid local / remote configuration storage library for node.js. |
|||
|
|||
## Installation |
|||
|
|||
### Installing npm (node package manager) |
|||
<pre> |
|||
curl http://npmjs.org/install.sh | sh |
|||
</pre> |
|||
|
|||
### Installing nconf |
|||
<pre> |
|||
[sudo] npm install nconf |
|||
</pre> |
|||
|
|||
## Usage |
|||
Using nconf is easy; it is designed to be a simple key-value store with support for both local and remote storage. Keys are namespaced and delimited by `:`. Lets dive right into sample usage: |
|||
|
|||
<pre> |
|||
var fs = require('fs'), |
|||
nconf = require('nconf'); |
|||
|
|||
// |
|||
// Setup nconf to user the 'file' store and set a couple of values; |
|||
// |
|||
nconf.use('file', { file: 'path/to/your/config.json' }); |
|||
nconf.set('database:host', '127.0.0.1'); |
|||
nconf.set('database:port', 5984); |
|||
|
|||
// |
|||
// Get the entire database object from nconf |
|||
// |
|||
var database = nconf.get('database'); |
|||
|
|||
// |
|||
// Save the configuration object to disk |
|||
// |
|||
nconf.save(function (err) { |
|||
fs.readFile('path/to/your/config.json', function (err, data) { |
|||
console.dir(JSON.parse(data.toString())) |
|||
}); |
|||
}); |
|||
</pre> |
|||
|
|||
## Storage Engines |
|||
|
|||
### Memory |
|||
|
|||
### File |
|||
|
|||
### Redis |
|||
|
|||
## More Documentation |
|||
|
|||
## Run Tests |
|||
Tests are written in vows and give complete coverage of all APIs and storage engines. |
|||
<pre> |
|||
vows test/*-test.js --spec |
|||
</pre> |
|||
|
|||
#### Author: [Charlie Robbins](http://www.charlierobbins.com) |
@ -1 +0,0 @@ |
|||
{"literal":"bazz","arr":["one",2,true,{"value":"foo"}],"obj":{"host":"localhost","port":5984,"array":["one",2,true,{"foo":"bar"}],"auth":{"username":"admin","password":"password"}}} |
@ -0,0 +1,27 @@ |
|||
require.paths.unshift(require('path').join(__dirname, 'lib')); |
|||
|
|||
var fs = require('fs'), |
|||
path = require('path'), |
|||
nconf = require('nconf'); |
|||
|
|||
//
|
|||
// Setup nconf to user the 'file' store and set a couple of values;
|
|||
//
|
|||
nconf.use('file', { file: path.join(__dirname, 'config.json') }); |
|||
nconf.set('database:host', '127.0.0.1'); |
|||
nconf.set('database:port', 5984); |
|||
|
|||
//
|
|||
// Get the entire database object from nconf
|
|||
//
|
|||
var database = nconf.get('database'); |
|||
console.dir(database); |
|||
|
|||
//
|
|||
// Save the configuration object to disk
|
|||
//
|
|||
nconf.save(function (err) { |
|||
fs.readFile(path.join(__dirname, 'config.json'), function (err, data) { |
|||
console.dir(JSON.parse(data.toString())) |
|||
}); |
|||
}); |
Loading…
Reference in new issue