Socket
Book a DemoInstallSign in
Socket

configo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configo

Hierarchical configuration with files and environment variables for node and the browser

0.1.2
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source
┌─┐┌─┐┌┐┌┌─┐┬┌─┐┌─┐
│  │ ││││├┤ ││ ┬│ │
└─┘└─┘┘└┘└  ┴└─┘└─┘

configo

Hierarchical configuration with files and environment variables for node and the browser.

NPM Version Code Climate

Install

npm i --save configo

Usage

1. Create a config folder at the root of your project. Within it, create a default folder.

mkdir config
mkdir config/default

2. Within the default folder, create a private.js file that exports an Object containing your private configuration variables. Once that's done, create a public.js file that does the same but for your publicly accessible configuration variables.

// ./config/default/private.js
module.exports = {
  WHO_IS_BATMAN: 'Bruce Wayne'
};
// ./config/default/public.js
module.exports = {
  NODE_ENV: process.env.NODE_ENV
};

3. Require configo on the server and in browsers (using browserify) and easily access your configuration variables.

// On the server
var conf = require('configo');

console.log(conf.get('WHO_IS_BATMAN')); // Bruce Wayne
console.log(conf.get('NODE_ENV'));      // production
// In browsers
var conf = require('configo');

console.log(conf.get('WHO_IS_BATMAN')); // undefined
console.log(conf.get('NODE_ENV'));      // production

NOTE: Your private configuration variables are not included in the outputted browserify file.

Functions

get(key)

Retrieves a key from your config.

Arguments

  • key - The variable you want to retrieve from your configuration.

Examples

var conf = require('configo');

var AWS_SECRET_KEY = conf.get('AWS_SECRET_KEY'); // SUPERSECRETAWSSECRETKEY

set(key, value)

Overwrites a variable in your configuration or sets a new one if the variable doesn't exist.

Arguments

  • key - The name of the variable you want to overwrite or sets it on your configo instance.
  • value - The value you want to store.

Examples

var conf = require('configo');

conf.set('FOO', 'bar');
console.log(conf.get('FOO')); // bar

Keywords

configuration

FAQs

Package last updated on 30 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.