ufp-lcars-config
v1.0.0
Published
LCARS configuration module
Downloads
4
Readme
ufp-lcars-config
This module is responsible for loading configuration from various sources and then combining them into a single runtime configuration.
examples
Two example "validator" objects exist: validators/allFeatures.js & validators/lcars.js.
The validators/lcars.js is intended to be used/extended by the main ufp-lcars project for which this module was created.
Executing the following code will:
- Load files beginning with the name ".name" from the source code's directory, the user's home, and the current working directory.
- After doing this it will map any config parameters detected in environment varibles; it will search for the values using environment variable names defined by a keyified
sanitizersin a very specific order: for example with "knex.connection.filename" `export knex.connection.filename="one.db"; export KNEX_CONNECTION_FILENAME="two.db"; ./example/bin - "UNIX_LIKE_CAPS_AND_UNDERSCORE"
API
Table of Contents
environment
Maps environment variables to "config" obj.
Parameters
validatorsObject An ideal config tree of functions that validato & validate values.envObject Environment variables as key/value.
Returns Object A configuration object with only settings from the environment present.
files
Parameters
validatorspathsArray Array of string locations to search for ".lcars.js" & ".lcars-environment.js" configuration files.fileNamesidealizedObject config property tree with optional functions to validate/sanitize values.
Returns Object technically only the config specified; but since this is where defaults arise it'll be everything really.
options
Parameters
validatorsargv{Array} Array of strings to be interpreted as options; process.argv without slicing 2 is fine & dealt with.
Returns Object Configration map of only options specified from command line.
unknown
boolean: [ "interactive", "terminal", "secure", "knex.debug", "secret" ],
Parameters
option
runtime
This constructs a singular configure object from the various sources.
Parameters
validatorsObject A tree of functions that define all keys; sanitize key values; and throw runtime errors on invalid key values.argvArray Array of strings, it's fine to include the first elements of process.argv.envObject Environment variables represented as a POJOpathsArray Array of strings that are paths to be searched for configuration.fileNamesArray Array of strings that are base names of files to be searched.
Returns object configuration object that is a mapped combination of these diverse sources.
validatorsToblank
Always returns an empty skeleton of a validators tree.
Parameters
validators
Returns Object configuration object
