Socket
Book a DemoInstallSign in
Socket

@kaliber/config

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kaliber/config

Zero dependency, minimal configuration library operating on CONFIG_ENV

0.0.8
latest
Source
npmnpm
Version published
Weekly downloads
1
-66.67%
Maintainers
4
Weekly downloads
 
Created
Source

A small, simple and dependency-free library for configuration

Recommendations

Do not use default.js for development values that are different in other environments. In other words: only use default.js for values that are the same for all environments.

Add local.js to your .gitignore file.

Usage

Define a configuration file

// config/test.js
module.exports = {
  my_config_value: 'test'
}

Use the configuration

// index.js
const { my_config_value } = require('@kaliber/config')
console.log(my_config_value)

Run the command with the correct environment

CONFIG_ENV=test node index.js

Usage from node

Define a configuration file

// config/test.js
module.exports = {
  my_config_value: 'test'
}

Load the configuration

// index.js
const load = require('@kaliber/config/load')
const { my_config_value } = load('test')
console.log(my_config_value)

Usage from the command line

Define a configuration file

// config/test.js
module.exports = {
  my_config_value: 'test'
}

Run the command with the correct environment

./node_modules/.bin/kaliber-config test my_config_value

When running in an NPM environment (scripts in package.json):

kaliber-config test my_config_value

Features

default.js and local.js

Order:

  • default.js
  • ${CONFIG_ENV}.js
  • local.js

So any value from local.js will override a value from one of the previous configuration files.

objects

Any nested objects will be combined.

Motivation

We used the config npm package but ran into trouble with out staging/acceptance environment. In that environment we wanted to compile with NODE_ENV=production for performance benefits of certain libraries.

We also ran into trouble when we forgot to set an environment variable, the config library provided a default instead of throwing an error.

Another motivation was that we only needed a very simple library, the config library is 1750 line file full of usefull options that we did not need.

Keywords

configuration

FAQs

Package last updated on 21 Apr 2021

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.