igthorn-config

1.0.1 • Public • Published

Igthorn Config

Igthorn

Basic wrapper for loading configuration.

Build Status

Igthorn Config package provides smart config file loading mechanism allowing to use local/remote config overwrites(using nconf package) without worry to commit them. This package is part of Igthorn project.

Usage

Typical usage would be to instantiate config(optionally passing filename and/or directory):

let Config = require("igthorn-config");
let config = new Config();
// this will load:
// appRootPath + "/config/app.json"
// and extend it with
// appRootPath + "/config/app.env.json"

// or
let Config = require("igthorn-config");
let config = new Config("test"); 
// this will load:
// appRootPath + "/config/test.json"
// and extend it with
// appRootPath + "/config/test.env.json"

// or
let appRootPath = require("app-root-path");
let Config = require("igthorn-config");
let config = new Config("main", appRootPath + "/settings");
// this will load:
// appRootPath + "/settings/main.json"
// and extend it with
// appRootPath + "/settings/main.env.json"

later config variable can be used in following way:

console.log(config.get("db:username"));

Methods

Config class implements following methods:

  • constructor(configFilename:string, configDirectoryPath:string) : self

    allows to pass custom config filename and/or config directory. Otherwise they are defaulting to:

    configFilename = "app" or NODE_ENV environment variable

    configDirectoryPath = appRootPath + "/config"

  • get(key:string): mixed

    returns key of configuration matched via passed key name

License

MIT

Package Sidebar

Install

npm i igthorn-config

Homepage

igthorn.com

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • hedonsoftware