0.0.3 â€ĸ Published 1 year ago

@graphshieldhq/configuration v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Versioning Twitter Follow

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:

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

Additional resources