A node module, inspired by Laravel's configuration class.
The module expects a folder called config within your application root (can be changed). It looks for .json files, which represent configuration files.
Example:
- config/app.json
- config/services.json
- config/auth.json
- config/database.json
- config/mail.json
$ npm install --save configuration-man
const config = require('configuration-man')();
You can pass the following options object to the configuration-man
.
basePath -> The application root folder.
configPath -> The folder that contains the configuration files.
const config = require('configuration-man')({
basePath: path.dirname(__filename),
configPath: "/config/"
});
You can use the following methods with the module.
Determine if the given configuration value exists. (Note: The first word before the dot, is the json file name.)
config.has('app.env') -> Check if the configuration file app.js
has a property called env
.
Get the specified configuration value. (Note: The first word before the dot, is the json file name.)
config.get('app.env') -> Get the property env
from the configuration file app.js
.
Set a given configuration value. (Note: The first word before the dot, is the json file name.)
config.set('app.env', 'Production') -> Set the property env
to Production
in the configuration file app.js
.
To run test cases, execute npm test
within the module folder.
MIT