Cutwater

Cutwater

  • Docs
  • Help
  • GitHub

Config

@codification/cutwater-core > Config

Class

A singleton to provide easy access to mutable configuration values.

beta:

Hierarchy

Config

Methods

  • get
  • getRequired
  • put

Methods

<Static> get

▸ get(key: string, defaultValue?: string): string

Defined in Config.ts:31

Returns the value associated with the key, checking first for values provided by the Config.put method and then from process.env. If the value is not found, the defaultValue is returned, or an empty string if that is not provided.

Parameters:

NameTypeDefault valueDescription
keystring-the configuration key
Default value defaultValuestring""the value to be returned if one is not found in the internal cache or environment variables

Returns: string


<Static> getRequired

▸ getRequired(key: string, errorMsg?: undefined | string): string

Defined in Config.ts:48

Returns the value associated with the key, checking first for values provided by the Config.put method and then from process.env. Unlike the Config.get method, an error is thrown if the value is not found, using the message specified if provided.

Parameters:

NameTypeDescription
keystringthe configuration key
Optional errorMsgundefined \stringthe error message to be used if there is no value for the key

Returns: string


<Static> put

▸ put(key: string, value: string): string

Defined in Config.ts:17

This will set the provided configuration key to the specified value. This does not make any changes to process.env, the key/value pair is stored in memory only.

Parameters:

NameTypeDescription
keystringthe configuration key
valuestringthe configuration value

Returns: string the previous configuration value if one existed


  • Class
  • Hierarchy
    • Methods
  • Methods
    • `` get
    • `` getRequired
    • `` put
Cutwater
Docs
Getting Started
Community
Stack Overflow
More
GitHubStar
Copyright © 2019 Codification.org