diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..008c66b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +config.json +test/fixtures/store.json \ No newline at end of file diff --git a/README.md b/README.md index e69de29..79def22 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,62 @@ +# nconf + +A hybrid local / remote configuration storage library for node.js. + +## Installation + +### Installing npm (node package manager) +
+  curl http://npmjs.org/install.sh | sh
+
+ +### Installing nconf +
+  [sudo] npm install nconf
+
+ +## 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: + +
+  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()))
+    });
+  });
+
+ +## Storage Engines + +### Memory + +### File + +### Redis + +## More Documentation + +## Run Tests +Tests are written in vows and give complete coverage of all APIs and storage engines. +
+  vows test/*-test.js --spec
+
+ +#### Author: [Charlie Robbins](http://www.charlierobbins.com) \ No newline at end of file diff --git a/test/fixtures/store.json b/test/fixtures/store.json deleted file mode 100644 index 1bea533..0000000 --- a/test/fixtures/store.json +++ /dev/null @@ -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"}}} \ No newline at end of file diff --git a/usage.js b/usage.js new file mode 100644 index 0000000..2e4d78f --- /dev/null +++ b/usage.js @@ -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())) + }); +}); \ No newline at end of file