Configuration library with validation using json-schema, compression, and encryption
The main goal of confiture is to provide configuration with:
- systematic validation using JSON schema.
- the option to compress the configuration file.
- the option to encrypt the configuration file.
Optionally, the configuration could be manipulated from a CLI using commander and json commander.
Version V2.x has been migrated from Javascript to Typescript.
Install
$ npm install --save confiture
Usage
Synchronously load some JSON
var confiture = ; var configurator = ; var conf = configurator;//Will load __dirname/appname/conf.json//conf will contain the configuration data//or an Error object if the validation has failed.
Asynchronously save some JSON through a stream
var confiture = ; var configurator = ; var conf = "email": "support@mycompany.com" "project": "bestProject"; var stream = configurator;//Will save the configuration in __dirname/appname/conf.json//and return a stream//or an Error object if the validation has failed.
Synchronously save some JSON
var confiture = ; var configurator = ; var conf = "email": "support@mycompany.com" "project": "bestProject"; var saveResult = configurator;//Will save the configuration in __dirname/appname/conf.json//and return OK//or an Error object if the validation has failed.
Compression
You can ask for the json file to be compressed. Only gz is supported at the moment.
var configurator = ; //The generated file name will be __dirname/appname/conf.json.gz
Encryption
You can ask for the json file to be encrypted. When encryption is on, compression is not supported though.
Most ciphers should be supported. You can check the list by typing:
;
Encrypted configuration:
var configurator = ; //The generated file name will be __dirname/appname/conf.json.aes-256-cbc
Backup
You can ask for the json file to be backed up before saving a new configuration.
var configurator = ; //The backup file name will be something like __dirname/appname/conf.json.bak-2015-05-02T17:44:25+01:00
Understanding the configuration
You can have an insight about the configuration by logging this:
console;
License
MIT © Olivier Huin