Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.3 KB

README.md

File metadata and controls

34 lines (26 loc) · 1.3 KB

Forest JS

Vault Library for NodeJS modified for Bareksa Environment Specific Usecase

Installation

npm install https://github.com/Bareksa/forest-js.git

Example Usage

const { Forest } = require('forest')

// Using https here will automatically attempts to use secure connection
// By default uses 'kv' engine. This can be set in the third param, which is config object
// See api docs for more detail.
// init only need to be called once in the app entry point.
Forest.init('token', 'http://localhost:8200')

// Initiate Forest as global manager to enable getString, and other helper methods globally
// Run this early as well if using global management
Forest.manageKeyValue('some-conf')
    .then(() => {
        const possibleStringKey = Forest.getString('somekey') // get value of key, but handled as if the value is string. No casting is done.
        const parseStringKey = Forest.parseString('somekey') // get value of key, but value is coerced to string. If value is object or array, it will be JSON stringified.
        const nestedKey = Forest.getString('some.nested.key') // if value is an object, you can get access to nested key this way.
        // There are more helpers. Check API Docs
    })
    .catch(console.error)