1.0.3 • Published 1 year ago
config-simpler v1.0.3
config-simpler Node Module
This node module lets you easily manage your configuration files and set or get some values from your config globaly.
Introduction IMPORTANT
You have to run the start command of your project in the project folder \
Like your project is stored in /home/user/project
then run node index.js
in the project folder
Features
- set key-value-pair
- get value of key
- supports dev and production mode
Features in coming
- async support
Quick start
Installation
$ npm install config-simpler
$ mkdir configs
$ vi configs/dev.json
OR
$ vi configs/prod.json
Run correctly
$ cd /home/user/project
$ NODE_ENV=development node index.js
use config-simpler correctly
const config = require("config-simpler");
// ...
const dbAddress = config.get('MariaDB.address');
db.connect(dbAddress, ...);
if (config.has('colorCode.red')) {...}
else {
let [key, value] = config.setNew('colorCode.red', "#ff0000"); // only if colorCode.red does NOT exist
}
[key, value] = config.override('colorCode.red', '#ff1122'); // only if colorCode.red does exist
[key, value] = config.set('lastname', 'Doe'); // doesn't matter if lastname exists or not