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.

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

  • Display the current ENV using either the logger you provide or console.log by default.

    Parameters

    Returns void

  • 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

  • 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

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

    Returns void

  • ConfigManager is a singleton.

    Parameters

    • Optionalspecs: 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

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

    Returns void