Configuration loader with directory support and a clean API


Confisto is a simple configuration loader for node.

  • Multiple parsers (currently only json included)
  • Can read directories with extra configuration files
  • Async

The API is fairly simple. The module exports a single function confisto.

  • file: File to load that contains the main configuration.
  • dir: Directory to read and load that contains many seperate configuration files. Optional.
  • defaults: Object with default values or path (string) to a file with default values. Optional.
  • parser: Parser to use while loading files Optional. (default 'json')

Function to call when done loading configurations.

  • err: Error in case of an error
  • configs: Object containing the result of merging the configuration files together
var confisto = require('confisto')
  file: 'my.conf'
, defaults: {
    logPath: '/var/log/my/errors.log'
  , dbconn: {
      host: ''
    , port: 1337
  , users: ['dan']  
}, function (errconfig) {
  if (err) {


{ "logPath": "templog.log
  "dbconn": {
    "host":  "localhost"
    "user":  "root"
  "users": ["joe"]

will print

{ logPath: 'templog.log'
, dbconn: {
    host: 'localhost'
  , user: 'root'  
, users: ['dan', 'joe']

Keep configuration object config under namespace ns so that it can be obtained from other files.

Get the configuration object of namespace ns

// file1.js 
var confisto = require('confisto')
  , func     = require('./file2')
  file: 'main.conf'
}, function (errconfig) {
  // handle err 
  confisto.keep('main', config)
// file2.js 
var confisto = require('confisto')
module.exports = function () {
  var mainConfig = config.get('main')