Skip to main content
Version: Next

ConfigReader

Home > @backstage/config > ConfigReader

An implementation of the Config interface that uses a plain JavaScript object for the backing data, with the ability of linking multiple readers together.

Signature:

class ConfigReader implements Config 

Implements: Config

Constructors

Constructor

Modifiers

Description

(constructor)(data, context, fallback, prefix)

Constructs a new instance of the ConfigReader class

Methods

Method

Modifiers

Description

fromConfigs(configs)

static

Instantiates the config reader from a list of application config objects.

get(key)

Same as getOptional, but will throw an error if there's no value for the given key.

getBoolean(key)

Same as getOptionalBoolean, but will throw an error if there's no value for the given key.

getConfig(key)

Same as getOptionalConfig, but will throw an error if there's no value for the given key.

getConfigArray(key)

Same as getOptionalConfigArray, but will throw an error if there's no value for the given key.

getNumber(key)

Same as getOptionalNumber, but will throw an error if there's no value for the given key.

getOptional(key)

Read out all configuration data for the given key.

Usage of this method should be avoided as the typed alternatives provide much better error reporting. The main use-case of this method is to determine the type of a configuration value in the case where there are multiple possible shapes of the configuration.

getOptionalBoolean(key)

Reads a configuration value at the given key, expecting it to be a boolean.

getOptionalConfig(key)

Creates a sub-view of the configuration object. The configuration value at the position of the provided key must be an object.

getOptionalConfigArray(key)

Creates a sub-view of an array of configuration objects. The configuration value at the position of the provided key must be an array of objects.

getOptionalNumber(key)

Reads a configuration value at the given key, expecting it to be a number.

getOptionalString(key)

Reads a configuration value at the given key, expecting it to be a string.

getOptionalStringArray(key)

Reads a configuration value at the given key, expecting it to be an array of strings.

getString(key)

Same as getOptionalString, but will throw an error if there's no value for the given key.

getStringArray(key)

Same as getOptionalStringArray, but will throw an error if there's no value for the given key.

has(key)

Checks whether the given key is present.

keys()

Lists all available configuration keys.