Coder Social home page Coder Social logo

node-cconf's Introduction

Build Status

CConf

A node.js module which holds the configuration of your node application. The configuration consists of required and optional key/value-pairs and their appropriate default values with the ability to load themselves from and write to files.

Installation

npm install --save git+https://github.com/christian-raedel/node-cconf.git#v0.3.3

Testing

cd /path/to/node-cconf
make install test

Documentation

cd /path/to/node-cconf
make install docs
$BROWSER doc/index.html

or browse API docs online

Basic Usage

var CConf = require('node-cconf')
    , https = require('https')
    , fs = require('fs');

// Create a new config named 'server' with the required keys 'port',
// 'https:cert' and 'https:key' and the given default values for the
// required keys.
var conf = new CConf('server', ['port', 'https:cert', 'https:key'], {
    port: 3000,
    https: {
        cert: fs.readFileSync(__dirname + '/.config/server.crt'),
        key: fs.readFileSync(__dirname + '/.config/server.key')
    }
});

// The 'load' method can be feeded with an ARGV array. So calling
// the script with 'node server.js --port=9000' will overwrite the
// default port.
conf.load(process.argv);

// Customize 'port' of the example server.
conf.setValue('port', 8080);

// Create an example https-server with previous defined configuration.
// As server options, the default values are taken and for the port
// to listen to, the configuration chooses the customized value.
var server = https.createServer(conf.getValue('https'))
.listen(conf.getValue('port'));

// When application ends, write the server configuration to a YAML file.
// Supported export targets are: JSON, YAML, Object and a custom
// function.
process.on('exit', function() {
    conf.save(__dirname + '/.config/server.yml');
});

node-cconf's People

Contributors

christian-raedel avatar incredible-io avatar

Stargazers

 avatar

Watchers

 avatar

node-cconf's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.