configuration

Pubbuild status

Automatic YAML configuration loader for Angel.

About

Any web app needs different configuration for development and production. This plugin will searchfor a config/default.yaml file. If it is found, configuration from it is loaded into app.configuration.Then, it will look for a config/$ANGEL_ENV file. (i.e. config/development.yaml). If this found, all of itsconfiguration be loaded, and will override anything loaded from the default.yaml file. This allows for yourapp to work under different conditions without you re-coding anything. :)

Installation

In pubspec.yaml:

  1. dependencies:
  2. angel_configuration: ^2.0.0

Usage

Example Configuration

  1. # Define normal YAML objects
  2. some_key: foo
  3. this_is_a_map:
  4. a_string: "string"
  5. another_string: "string"

You can also load configuration from the environment:

  1. # Loaded from the environment
  2. system_path: $PATH

If a .env file is present in your configuration directory, then it will be loaded beforeapplying YAML configuration.

Server-sideCall configuration(). The loaded configuration will be available in your application'sconfiguration map.

configuration also accepts a sourceDirectory or overrideEnvironmentName parameter.The former will allow you to search in a directory other than config, and the latter lets youoverride $ANGEL_ENV by specifying a specific configuration name to look for (i.e. production).

This package usespackage:merge_mapinternally, so existing configurations can be deeply merged.

Example:

  1. # default.yaml
  2. foo:
  3. bar: baz
  4. quux: hello
  5.  
  6. # production.yaml
  7. foo:
  8. quux: goodbye
  9. yellow: submarine
  10.  
  11. # Propagates to:
  12. foo:
  13. bar: baz
  14. quux: goodbye
  15. yellow: submarine