Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 709 Bytes

README.md

File metadata and controls

30 lines (20 loc) · 709 Bytes

njs-tfso-secret

Get secret values from file

Try to read file and returns content as value. Name of file is name of key, file location is determined by config.

Note: Reading is sync. Use only on startup.

install

npm install tfso/njs-tfso-secret

usage

const secret = require('njs-tfso-secret');
 
let value = secret.get('some-secret', 'somedefaultvalue');

 
//custom config
secret.config({
    location: '/run/secrets', // default
    silent: false // if false, log to console if error reading keys from file. Default is "true"
});
 

// use together with getenv
const env = require('getenv');

let valueWithDefaultFromEnv = secrets.get('PASSWORD',env.string('PASSWORD', ''))