platform/packages/configuration
2024-05-22 00:26:09 +08:00
..
example Publish angel3_configuration 2021-05-14 19:27:54 +08:00
lib Upgraded to min SDK 2.17 2022-08-14 10:17:59 +08:00
test Updated linter to package:lints 2021-09-25 14:32:32 +08:00
.gitignore Publish angel3_configuration 2021-05-14 19:27:54 +08:00
analysis_options.yaml Updated linter to package:lints 2021-09-25 14:32:32 +08:00
AUTHORS.md Publish angel3_configuration 2021-05-14 19:27:54 +08:00
CHANGELOG.md Updated repository links 2023-12-25 11:45:10 +08:00
LICENSE Updated linter to package:lints 2021-09-25 14:32:32 +08:00
melos_angel3_configuration.iml Added melos 2022-03-19 09:37:28 +08:00
pubspec.yaml Updated lints 2024-05-22 00:26:09 +08:00
README.md Updated repository links 2023-12-25 11:45:10 +08:00

Angel3 Configuration Loader

Pub Version (including pre-releases) Null Safety Gitter License

Automatic YAML configuration loader for Angel3 framework

About

Any web app needs different configuration for development and production. This plugin will search for 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 its configuration be loaded, and will override anything loaded from the default.yaml file. This allows for your app to work under different conditions without you re-coding anything. :)

Installation

In pubspec.yaml:

dependencies:
    angel3_configuration: ^6.0.0

Usage

Example Configuration

# Define normal YAML objects
some_key: foo
this_is_a_map:
  a_string: "string"
  another_string: "string"
  

You can also load configuration from the environment:

# Loaded from the environment
system_path: $PATH

If a .env file is present in your configuration directory (i.e. config/.env), then it will be loaded before applying YAML configuration.

You can also include values from one file into another:

_include:
  - "./include-prod.yaml"
  - "./include-misc.yaml"
_include: "just-one-file.yaml"

Server-side Call configuration(). The loaded configuration will be available in your application's configuration 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 you override $ANGEL_ENV by specifying a specific configuration name to look for (i.e. production).

This package uses package:angel3_merge_map internally, so existing configurations can be deeply merged.

Example:

# default.yaml
foo:
  bar: baz
  quux: hello
  
# production.yaml
foo:
  quux: goodbye
  yellow: submarine
  
# Propagates to:
foo:
  bar: baz
  quux: goodbye
  yellow: submarine