s-conf

1.0.0 • Public • Published

s-conf

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

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

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i s-conf

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • fgascon