You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-3Lines changed: 31 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -504,16 +504,17 @@ TypedConfigModule.forRoot({
504
504
});
505
505
```
506
506
507
-
## Uses of environment variable substitutions
507
+
## Uses of variable substitutions
508
508
509
-
The `${PORT}` substitution feature lets you use environment variable in some nice ways.
509
+
The `${PORT}` substitution feature lets you use environment variable in some nice ways. You can also provide default values, and reference another variable in a config
510
510
511
511
If you have config file with like the below one
512
512
513
513
```yaml
514
514
database:
515
515
host: 127.0.0.1
516
-
port: ${PORT}
516
+
port: ${PORT:-12345}
517
+
url: ${database.host}:${database:port}
517
518
```
518
519
519
520
And you have set environment variable for port
@@ -537,6 +538,33 @@ And you will get new config like below one
537
538
database:
538
539
host: 127.0.0.1
539
540
port: 9000
541
+
url: 127.0.0.1:9000
542
+
```
543
+
544
+
if you won't set environment variable for port, then you will get new config like below one
545
+
546
+
```yaml
547
+
database:
548
+
host: 127.0.0.1
549
+
port: 12345
550
+
url: 127.0.0.1:12345
551
+
```
552
+
553
+
> [!NOTE]
554
+
> when you use variable substitution the values can be string in case if you use default variable or env variable, and you need to apply transformer to class fields to get the correct type of the value.
0 commit comments