@fjandin/config-man
TypeScript icon, indicating that this package has built-in type declarations

1.7.0 • Public • Published

NodeJS Configuration Manager

Install

yarn add @fjandin/config-man

Initialize

Add [ProjectRoot]/config-man.json file

{
    "schema": [{"key": "server.port", "type": "number", "default": 8080, "nullable": false}]
}
import * as configMan from '@fjandin/config-man'

configMan.init({
    cwd: __dirname,
    removeUnknown: true,
    configs: [
        {type: configMan.ConfigType.DEFAULT},
        {type: configMan.ConfigType.DYNAMODB, tableName: 'Configuration-Table', region: 'eu-west-1'},
        {type: configMan.ConfigType.JAVASCRIPT, filepath: path.resolve('config.js')},
        {type: configMan.ConfigType.JSON, filepath: path.resolve('config.json')},
        {type: configMan.ConfigType.ARG, prefix: 'CM_'},
        {type: configMan.ConfigType.ENV, prefix: 'CM_},
    ]
});

async function startApp() {
    // Wait for config to be ready
    await configMan.ready;

    const port = configMan.get('server.port');
    // etc...
}

/@fjandin/config-man/

    Package Sidebar

    Install

    npm i @fjandin/config-man

    Weekly Downloads

    1,670

    Version

    1.7.0

    License

    MIT

    Unpacked Size

    41.5 kB

    Total Files

    40

    Last publish

    Collaborators

    • fjandin