178178
179179
180180 < p > < a href ="https://travis-ci.org/C2FO/gofigure "> < img src ="https://travis-ci.org/C2FO/gofigure.png " alt ="Build Status "> </ a > </ p >
181- < h1 > gofigure</ h1 >
181+ < h1 id =" gofigure " > gofigure</ h1 >
182182< p > Gofigure is a configuration tool for node to help in the gathering and monitoring of configuration files in node.</ p >
183- < h1 > Installation</ h1 >
183+ < h1 id =" installation " > Installation</ h1 >
184184< p > For nodejs >= 0.10 and iojs:</ p >
185185< pre class ='prettyprint linenums lang-js '> < code > $ npm install gofigure</ code > </ pre >
186186< p > For nodejs < 0.10:</ p >
187187< pre class ='prettyprint linenums lang-js '> < code > $ npm install gofigure@0.1.2</ code > </ pre >
188- < h1 > Usage</ h1 >
188+ < h1 id =" usage " > Usage</ h1 >
189189< ul >
190190< li > < a href ="#load "> Loading A Configuration</ a > < ul >
191191< li > < a href ="#loadDir "> Directories</ a > </ li >
@@ -204,7 +204,7 @@ <h1>Usage</h1>
204204< li > < a href ="#type "> Node Type</ a > </ li >
205205</ ul >
206206< p > < a name ="load "> </ a > </ p >
207- < h2 > Loading configurations</ h2 >
207+ < h2 id =" loading-configurations " > Loading configurations</ h2 >
208208< p > Gofigure currently handles the loading of JSON files for configurations.</ p >
209209< p > To Get an instance of a configuration object use the < code > gofigure</ code > method. The < code > gofigure</ code > method takes an object that accepts the following options</ p >
210210< ul >
@@ -238,7 +238,7 @@ <h2>Loading configurations</h2>
238238var loader = gofigure({locations : [__dirname + "/configs"]});
239239var config = loader.loadSync();</ code > </ pre >
240240< p > < a name ="loadDir "> </ a > </ p >
241- < h3 > Directories of configurations</ h3 >
241+ < h3 id =" directories-of-configurations " > Directories of configurations</ h3 >
242242< p > To load directories that contain configuration files in the options object provide locations property that is an array of directories than contain your configurations.</ p >
243243< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript ">
244244var gofigure = require("gofigure");
@@ -264,7 +264,7 @@ <h3>Directories of configurations</h3>
264264 var PORT = config.port, HOST = config.host;
265265});</ code > </ pre >
266266< p > < a name ="loadFiles "> </ a > </ p >
267- < h3 > Files</ h3 >
267+ < h3 id =" files " > Files</ h3 >
268268< p > You may also load specific files rather than entire directories.</ p >
269269< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> var gofigure = require("gofigure");
270270
@@ -274,7 +274,7 @@ <h3>Files</h3>
274274});</ code > </ pre >
275275< p > Again order matters < code > /prod/configs/config1.json</ code > will override < code > __dirname + "/config.json"</ code > </ p >
276276< p > < a name ="loadEtcd "> </ a > </ p >
277- < h3 > Etcd</ h3 >
277+ < h3 id =" etcd " > Etcd</ h3 >
278278< p > You may also load from a centralized Etcd server.</ p >
279279< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> var gofigure = require("gofigure");
280280
@@ -308,10 +308,10 @@ <h3>Etcd</h3>
308308 var PORT = config.port, HOST = config.host;
309309});</ code > </ pre >
310310< p > < a name ="monitoring "> </ a > </ p >
311- < h2 > Monitoring</ h2 >
311+ < h2 id =" monitoring " > Monitoring</ h2 >
312312< p > Gofigure supports the monitoring of changes to configuration files.</ p >
313313< p > < a name ="monitoringAll "> </ a > </ p >
314- < h3 > All files or Etcd server</ h3 >
314+ < h3 id =" all-files-or-etcd-server " > All files or Etcd server</ h3 >
315315< p > To enable monitoring you can specify monitor to true in the options.</ p >
316316< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> var gofigure = require("gofigure");
317317
@@ -322,7 +322,7 @@ <h3>All files or Etcd server</h3>
322322 //...do something
323323});</ code > </ pre >
324324< p > < a name ="monitoringSome "> </ a > </ p >
325- < h3 > Individual Files</ h3 >
325+ < h3 id =" individual-files " > Individual Files</ h3 >
326326< p > To monitor certain files you can use the files property and with object that have a < code > monitor : true</ code > KV pair.</ p >
327327< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> var gofigure = require("gofigure");
328328
@@ -341,7 +341,7 @@ <h3>Individual Files</h3>
341341});</ code > </ pre >
342342< p > Just < code > config1.json</ code > will be monitored for changes.</ p >
343343< p > < a name ="monitoringSyntax "> </ a > </ p >
344- < h3 > Property topic syntax</ h3 >
344+ < h3 id =" property-topic-syntax " > Property topic syntax</ h3 >
345345< p > To listen to all properties</ p >
346346< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> loading.on(function(config){
347347 //...do something
@@ -397,7 +397,7 @@ <h3>Property topic syntax</h3>
397397 //...do something
398398});</ code > </ pre >
399399< p > < a name ="monitoringCB "> </ a > </ p >
400- < h3 > Callback Arguments</ h3 >
400+ < h3 id =" callback-arguments " > Callback Arguments</ h3 >
401401< p > The property change callback will pass in the following values depending on the arity of the callback.</ p >
402402< p > If 1 argument is expected then just the callback invoked with the new value is a.</ p >
403403< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript ">
@@ -415,14 +415,14 @@ <h3>Callback Arguments</h3>
415415 //...do something
416416});</ code > </ pre >
417417< p > < a name ="environments "> </ a > </ p >
418- < h2 > Environments</ h2 >
418+ < h2 id =" environments " > Environments</ h2 >
419419< p > < strong > Reserved Property Names</ strong > </ p >
420420< p > The following environment names are reserved and not be used when process.env.NODE_ENV or < code > environment</ code > is set.</ p >
421421< ul >
422422< li > < code > *</ code > </ li >
423423< li > < code > type</ code > </ li >
424424</ ul >
425- < h3 > NODE_ENV</ h3 >
425+ < h3 id =" node_env " > NODE_ENV</ h3 >
426426< p > < code > gofigure</ code > also supports environments, by default it will look for < code > NODE_ENV</ code > and if it is set then it will use it.</ p >
427427< p > The following is an example configuration file</ p >
428428< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript ">
@@ -573,7 +573,7 @@ <h3>NODE_ENV</h3>
573573 }
574574}</ code > </ pre >
575575< p > Now each environment only has to override properties specific to that env.</ p >
576- < h3 > Using NODE_ENV with Etcd</ h3 >
576+ < h3 id =" using-node_env-with-etcd " > Using NODE_ENV with Etcd</ h3 >
577577< p > The expected layout within Etcd is the following:</ p >
578578< p > < code > 127.0.0.1:4001/v2/keys/<root>/<NODE_ENV></ code > </ p >
579579< p > So, in the example above, < code > gofigure</ code > will look for the following:</ p >
@@ -585,7 +585,7 @@ <h3>Using NODE_ENV with Etcd</h3>
585585< p > at this location within Etcd for keys:</ p >
586586< p > 127.0.0.1:4001/v2/keys/appname/production</ p >
587587< p > < a name ="type "> </ a > </ p >
588- < h2 > NODE_TYPE</ h2 >
588+ < h2 id =" node_type " > NODE_TYPE</ h2 >
589589< p > < strong > NOTE</ strong > This is to used with < a href ="#environments "> < code > NODE_ENV</ code > </ a > .</ p >
590590< p > Since Etcd is a centralized configuration store, the concept of a node type needs to be introduced. By default < code > gofigure</ code > will look for < code > NODE_TYPE</ code > and, if it is set, then it will use it. To programmatically load just the production webapp properties set, the < code > environment</ code > to production and < code > nodetype</ code > to webapp.</ p >
591591< pre class ='prettyprint linenums lang-js '> < code class ="lang-javascript "> var gofigure = require("gofigure");
@@ -652,7 +652,7 @@ <h2>NODE_TYPE</h2>
652652 "host" : "dev.mydomain.com",
653653 "port" : "6060"
654654}</ code > </ pre >
655- < h3 > Using NODE_TYPE with Etcd</ h3 >
655+ < h3 id =" using-node_type-with-etcd " > Using NODE_TYPE with Etcd</ h3 >
656656< p > When using < code > NODE_TYPE</ code > with Etcd your URI would look like the following</ p >
657657< pre class ='prettyprint linenums lang-js '> < code > 127.0.0.1:4001/v2/keys/<root>/type/<NODE_ENV>/<NODE_TYPE></ code > </ pre >
658658< p > To load Etcd with a < code > NODE_TYPE</ code > your code could look like the following.</ p >
@@ -663,9 +663,9 @@ <h3>Using NODE_TYPE with Etcd</h3>
663663< p > < code > gofigure</ code > would generate the following URI to retrieve the type config from Etcd.</ p >
664664< p > < strong > NOTE</ strong > gofigure would also load the < code > NODE_ENV</ code > uri discussed above.</ p >
665665< pre class ='prettyprint linenums lang-js '> < code > 127.0.0.1:4001/v2/keys/appname/type/production/webapp</ code > </ pre >
666- < h2 > License</ h2 >
666+ < h2 id =" license " > License</ h2 >
667667< p > MIT < a href ="https://github.com/C2FO/gofigure/raw/master/LICENSE "> https://github.com/C2FO/gofigure/raw/master/LICENSE</ a > </ p >
668- < h2 > Meta</ h2 >
668+ < h2 id =" meta " > Meta</ h2 >
669669< ul >
670670< li > Code: < code > git clone git://github.com/c2fo/gofigure.git</ code > </ li >
671671< li > Website: < a href ="http://c2fo.com "> http://c2fo.com</ a > - Twitter: < a href ="http://twitter.com/c2fo "> http://twitter.com/c2fo</ a > - 877.465.4045</ li >
0 commit comments