Skip to content

Commit c69548b

Browse files
authored
Improve documentation around application configuration.
1 parent 790bd96 commit c69548b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ The initialization process proceeds in a series of phases, giving the initializi
5050

5151
Most applications won't need to do anything special at all.
5252

53+
### Application Configuration
54+
55+
When the application loads, a list of known environment variables is loaded from `process.env` into an object which it exposes via `getConfig` - the point here is primarily to isolate our code from usages of `process.env` which may not always be the way we choose to configure our apps. The application initialization lifecycle runtime configuration as well via the `config` handler, documented in the [initialization function](https://edx.github.io/frontend-platform/module-Initialization.html#~initialize). If you want to get a variable into the config that it’s not expecting, you can use [`mergeConfig`](https://edx.github.io/frontend-platform/module-Config.html#~mergeConfig) during initialization to add it in from `process.env`.
56+
57+
Such an example might look like:
58+
59+
```
60+
initialize({
61+
// ... other initialization options
62+
handlers: {
63+
config: () => {
64+
mergeConfig({
65+
CUSTOM_VARIABLE: process.env.CUSTOM_VARIABLE || null,
66+
}, 'Custom app config');
67+
},
68+
},
69+
});
70+
```
71+
5372
### Service interfaces
5473

5574
Each service (analytics, auth, i18n, logging) provided by frontend-platform has a API contract which all implementations of that service are guaranteed to fulfill. Applications that use frontend-platform can use its configured services via a convenient set of exported functions. An application that wants to use the service interfaces need only initialize them via the initialize() function, optionally providing custom service interfaces as desired (you probably won't need to).

0 commit comments

Comments
 (0)