https://github.com/ericwindmill/web_app_config
https://github.com/ericwindmill/web_app_config
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ericwindmill/web_app_config
- Owner: ericwindmill
- License: bsd-2-clause
- Created: 2018-08-18T19:58:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-20T15:13:11.000Z (almost 8 years ago)
- Last Synced: 2025-12-13T12:23:17.180Z (6 months ago)
- Language: Dart
- Size: 27.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# web_app_config
Tools to configure Dart web apps using environment variables.
## Example
The example/ directory contains an example project.
When the server runs, it writes a config.json file based on
the desired environment variables:
```dart
const List supportedKeys = const [
'app_name',
'app_description',
'app_version',
];
Future main() async {
await wconfig.writeConfigFromEnvironment(supportedKeys);
// ...
```
Then, when the client runs, that configuration can be loaded
and parsed into a map:
```
const List supportedKeys = const [
'app_name',
'app_description',
'app_version',
];
Future main() async {
await wconfig.writeConfigFromEnvironment(supportedKeys);
```
When app is run in development mode, (`pub serve` or `webdev serve`) the
configuration is loaded from `web/config.yaml`
```bash
pub build # Dart 2: webdev build
dart bin/server.dart
# observe the app says "name: my awesome app", configured in config.yaml
# stop server
export APP_NAME="i am configured using an env var"
dart bin/server.dart
# observe the app now says "name: i am configured using an env var"
# stop server
unset APP_NAME
dart bin/server.dart
# observe the app says "name: my awesome app" again
```