Neverending Perpetual Motion
    Have ideas to improve npm?Join in the discussion! »

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

    0.4.1 • Public • Published

    @restorecommerce/service-config

    An opinionated wrapper of nconf.

    Configuration settings are obtain from the following sources in the given order:

    1. Command argument
    2. Environment variables
    3. Configuration files

    1.) and 2.) support passing nested object properties with the following pattern:

    # Original Configuration JSON file
    {
      "someObject": {
        "paramA": "A"
      }
    }

    Can be overridden via env var or command line parameter someObject__paramA. So the nesting is designated by a double underscore.

    3.) tries to load the following configuration files from the cfg folder:

    • Default configuration file config.json
    • Additional sub-variants added to the value of the environment variable NODE_ENV for example a value development:development would try to load config_development.json

    Usage

    import { createServiceConfig } from '@restorecommerce/service-config';
    
    ...
    
    const cfg = createServiceConfig('./test', { stageVar: 'NODE_ENV', logger: logger});
    const testSetting = cfg.get('test');

    Install

    npm i @restorecommerce/service-config

    DownloadsWeekly Downloads

    199

    Version

    0.4.1

    License

    MIT

    Unpacked Size

    9.78 kB

    Total Files

    11

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar