Skip to content

Commit 61cd9f7

Browse files
authored
Merge pull request #149 from HarperDB/load-component-env-vars
add env loading to component docs
2 parents 58ae12f + 5c80e4a commit 61cd9f7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/developers/components/built-in.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Harper provides extended features using built-in components. They do **not** nee
77
- [graphql](#graphql)
88
- [graphqlSchema](#graphqlschema)
99
- [jsResource](#jsresource)
10+
- [loadEnv](#loadenv)
1011
- [rest](#rest)
1112
- [roles](#roles)
1213
- [static](#static)
@@ -66,6 +67,29 @@ jsResource:
6667
files: './resource.js'
6768
```
6869

70+
## loadEnv
71+
72+
Load environment variables via files like `.env`.
73+
74+
This component is a [Resource Extension](./reference.md#resource-extension) and can be configured with the [`files`, `path`, and `root`](./reference.md#resource-extension-configuration) configuration options.
75+
76+
Ensure this component is specified first in `config.yaml` so that environment variables are loaded prior to loading any other components.
77+
78+
```yaml
79+
loadEnv:
80+
files: '.env'
81+
```
82+
83+
This component matches the default behavior of dotenv where existing variables take precedence. Specify the `override` option in order to override existing environment variables assigned to `process.env`:
84+
85+
```yaml
86+
loadEnv:
87+
files: '.env'
88+
override: true
89+
```
90+
91+
> Important: Harper is a single process application. Environment variables are loaded onto `process.env` and will be shared throughout all Harper components. This means environment variables loaded by one component will be available on other components (as long as the components are loaded in the correct order).
92+
6993
<!-- ## login -->
7094

7195
<!-- ## mqtt -->

0 commit comments

Comments
 (0)