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

json-config-ts

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-config-ts

Easy-to-use config storage via JSON with optional base-64 encryption for sensitive data

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-68.18%
Maintainers
1
Weekly downloads
 
Created
Source

json-config-ts

Build Status npm version

Easy-to-use config storage via JSON with optional base-64 encryption for sensitive data

Install

$ npm i -S json-config-ts

Usage

const Store = require('json-config-ts')
const store = new Store({
	directory: '/home',
	collection: 'foods',
	name: 'fruits',
	encryptedFields: ['creds.password'],
	defaultData: {
		apples: 2,
		oranges: 5,
		creds: {
			username: 'admin',
			password: 'password'
		}
	}
})

Specs

  • Config store in DIRECTORY/.json_config/COLLECTION/NAME.json
    • Directory argument is optional, if not provided, homedir is used
    • Collection argument is optional, if not provided, no additional collection folder is created

Params

  • String name: config name
  • String directory: database directory (optional directory to store JSON configs)
  • String collection: collection name (optional folder for json file)
  • Object defaultData: default data if json file does not exist
  • Array[string] encryptedFields: fields to be encrypted (in field.name form for nested keys)

Methods

  • data
    • returns unencrypted object
  • load()
    • loads current data from file, useful when updating config from concurrent processes
  • get(key)
    • gets value from path
  • set(key, value)
    • set value for path
  • update(data)
    • update config with object (preserves object structure and updates nested objects/properties)
  • write(data)
    • overwrites config with object
  • clear()
    • clears config and writes empty object

Documentation

Keywords

FAQs

Package last updated on 12 Sep 2020

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