Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

konvenient Examples and Recipes

Configuration is best if it's as konvenient as possible. Here you find a few examples and recipes to get you started as quickly as possible.

Recipes

Smaller scale code snippets, showcasing a single feature of the library.

Run any of them with npm from the this directory, for example, npm run example:01 (pro tip: make sure to run npm install in this directory as beforehand).

  • 01 Simple Usage
    • The Quickstart code of the main README. Nothing fancy, just loading a value.
  • 02 Result
    • Transforming the loaded value using the result function.
  • 03 Computed
    • Define functions/getters on configuration classes to compute new values from what is loaded.
  • 04 Env Var Prefix
    • Specify a common, application-specific prefix for every environment variable.
  • 05 Nested
    • Configuration classes as fields.
  • 06 Inversify
    • konvenient-inversify interoperability: put configuration classes into inversify containers and inject them.
  • 07 Nested Env Var
    • Environment variable name derivation.
  • 08 Simple File
    • Load configuration values from JSON files.
  • 09 YAML File
    • Load configuration values using a custom parser, from YAML files.
  • 10 No Prefix
    • Load configuration values as top level properties.
  • 11 Inheritance
    • Inherit configurable properties from other configuration classes.

Examples

Somewhat larger modules, exercising multiple parts of konvenient.

Run any of them with npm from the this directory, for example, npm run recipe:01 (pro tip: make sure to run npm install in this directory as beforehand).

  • 01 File Dependent, Single, Top-Level
    • Loading configuration values from a file.
    • Configuration is stored in a single TypeScript class.
    • The properties in the configuration class are top-level ones in the configuration files.
  • 02 File Dependent, Multiple, Inversify
    • Loading configuration values from a file.
    • Configuration is stored in muiltiple TypeScript classes.
    • Configuration classes are managed by inversify.