1.0.0 • Published 8 years ago

s-conf v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

s-conf

Service configuration based on JSON file. The config file path is given as the first command line argument (argv2).

Usage

Call your node service like this: $ node index.js config.json

var config = require('s-conf');
var http = require('http');

http.createServer(function(req, res){
  res.end("Hello!");
}).listen(config.require('http_port'), config.get('http_ip', '0.0.0.0'));

http_port is mandatory and http_ip is optional and default to '0.0.0.0'.

API

config.require(name)

To get a mandatory config parameter.

config.get(name, defaultValue)

To get an optional config parameter. It will default to defaultValue if name is not present in the config file.

config.watch(changeListener)

Watch for config reload

config.reload(callback)

Reload the config from the config file