ConfigUnit

libflitter/config/ConfigUnit~ ConfigUnit

The config unit loads the configuration files from a specified directory and, after merging them with values from a .env file, loads them into the global accessor daemon, config().

Constructor

new ConfigUnit(config_directoryopt)

Source:

Instantiate the unit. Resolve the path to the directory with the configuration files.

Parameters:
Name Type Attributes Default Description
config_directory string <optional>
'./config'

the path to the directory with the configuration files

Extends

Methods

(async) cleanup(app) → {Promise.<void>}

Source:
Inherited From:

Cleans up the unit's resources before Flitter closes.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

directories() → {Object}

Source:
Overrides:

Get the directories provided by the unit. Currently, "config" mapped to module:libflitter/config/ConfigUnit~ConfigUnit#directory

Returns:
Type
Object

getconfig(accessor) → {string|*}

Source:

A helper function to get configuration values by period-delineated name. This is usually bound to the relevant module:libflitter/app/FlitterApp~FlitterApp.

Parameters:
Name Type Description
accessor string

period-delineated access string

Returns:
Type
string | *

(async) go(app, context) → {Promise.<void>}

Source:
Overrides:

Loads the unit. Starts the 'dotenv' package and imports configurations from module:libflitter/config/ConfigUnit~ConfigUnit#directory. Binds the configuration and helper functions to the appropriate contexts.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

context module:libflitter/Context~Context

the Unit's context

Returns:
Type
Promise.<void>

name() → {string}

Source:
Overrides:

Get the name of the unit.

Returns:

"config"

Type
string

templates() → {Object}

Source:

Get the templates provided by this unit. Currently, "config" provided by module:libflitter/templates/config

Returns:
Type
Object