Class ConfigManager

The ConfigManager class is where everything happens.

The ConfigManager allows you loading your config specs definition, it also loads your actual config and lets you access it.

Hierarchy

  • ConfigManager

Constructors

Properties

config: ConfigObject
instance: ConfigManager

Methods

  • This Getter is the safest way to access your configuration values as it will throw errors in case you try access an invalid module/key

    Parameters

    • mod: string
    • key: string

    Returns any

  • Validate the config and return wheather it is valid or not

    Returns boolean

  • Validate a single field.

    Parameters

    • module: string
    • key: string

      Key of the field

    Returns boolean

  • This retrieves the config and fills defaults. Additionnaly, the config object you get is decorated with a few helper fonctions such as Print, Validate, etc... to help you easily use your config

    Returns ConfigObject

  • Check wether the key is valid. We assume here that the module does exist

    Parameters

    • mod: string
    • key: string

    Returns boolean

  • Check whether the module mod is part of ours specs

    Parameters

    • mod: string

    Returns boolean

  • Does not touch the ENV but rebuild the config. This is useful if you know that the ENV changed

    Returns void

  • You likely will never have to use this function which is mostly use for the tests. If you don't know, do NOT call this function, it would take time and likely do nothing interesting for you.

    Returns void

  • This is the actual function performing the validation of a given field according to the spcs

    Parameters

    Returns boolean

  • You should not use this function. It is there only for testing.

    Returns void

  • This function defines what '.env' file will be loaded. By default, '.env' will be used. However, if you pass NODE_ENV=abc, the loaded file will be .env.abc

    Returns string

  • ConfigManager is a singleton.

    Parameters

    • Optional specs: string | ConfigSpecs

      The config specs the ConfigManager will rely on. It can be a ConfigSpecs object or the path of a file. In that case, the file can be either a YAML file or a JSON file.

    Returns ConfigManager

  • Parameters

    • r: RegExp | RegexpWithAttributes

    Returns r is RegexpWithAttributes

  • Calling this function will get an instance of the Config and attach it to the global scope.

    Returns void

  • This function converts a string to a boolean. It ignores the case and support also values such as 0 and 1, yes and no.

    Parameters

    • s: string

      String to convert

    Returns boolean

Generated using TypeDoc