@graphshieldhq/configuration
v0.0.3
Published
An opinionated configuration management module based ont the 12 factors principles
Downloads
5
Maintainers
Readme
Configuration Module
An opinionated configuration management module based ont the 12 factors principles.
💡 Features
Consistent configuration specifications
Easy configuration specifications through a simple schema. See the specifications sample for reference.
Self-documentation
Maintaing configuration documentation is hard. This module can automatically generate key configuration documents:
- Configuration reference: A markdown file that documents the configuration keys. See the configuration reference example.
- .env sample: A sample dotenv file based on the configuration options default values. See the sample .env file
Relies on environment variables
As a best practice, this module strictly relies on environment variables for portability.
If you're using dotenv files, they should be loaded as environment variables outside of your app process, using a module such as dotenv:
node --require dotenv/config src/index.js dotenv_config_path=./.env
Flat configuration
This module generates an configuration object with a flat structure to avoid nested and hard to maintain configuration objects.
🚀 Get Started
Installation
npm install --save @graphshieldhq/configuration
Initialization
import specifications from './specifications.js'
import configuration from '@graphshieldhq/configuration'
configuration.init({
specifications,
options: {
log_keys_values: false,
exit_process_on_missing_mandatory_key: false,
log_missing_mandatory_key_values: true
}
})
The initialization options must be an object with properties as specified in the options schema.
Usage
// Instead of using
process.env.KEY
// Just use
configuration.env.KEY