New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@logzio-node-toolbox/config

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logzio-node-toolbox/config

config manager based on Joi schema with subscription capabilities

  • 0.0.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-25.38%
Maintainers
3
Weekly downloads
 
Created
Source

Config

an efficient config manager based on Joi schema for better easy managing configurations

Usage

import { Config } from '@logzio-node-toolbox/config';

const schema = {}; // Joi schema or array of Joi schemas (in case or array will merge the schemas)

const defaults = {}; // defaults to override the schema defaults (use to pass defaults per region or environment)

const overrides = {}; // configs that could never be override even when try to set (usually environment variables)

const config = new Config({ schema, defaults, overrides });

get value

use path to fetch nested value, if empty will fetch the all config

const value = config.get('path.to.value');

set value

use path in key property to set nested values, if empty will mergeDeep from root

onError - callback for when validation error with the schema, if onError return true will continue with the merge config even if not valid

config.set({ value: {}, key = 'path.to.set', onError: (err) => {
  console.log(err)
  return true;
} })

subscribe

onChange - callback to invoke when value changed if key is empty will watch all config

return unSubscribe method

const unSubscribe = config.subscribe({ key: 'path.to.value.to.watch', onChange: (value) => {
  console.log("new value:", value);
}})

unSubscribe(); // stop watching value

FAQs

Package last updated on 07 Nov 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc