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
const config =builder.build(); // This is the result of combining dev and basic.
56
+
```
57
+
58
+
59
+
Use configuration.
60
+
61
+
```typescript
62
+
config.get(); // The whole configuration created comes out
63
+
config.get('a.b.c'); // Is same as config.get().a.b.c
64
+
```
65
+
66
+
67
+
68
+
*Each of Environments and Sources are merged by [deepmerge](#reference).(What is added first has high priority)*
69
+
You can set deepmerge options as follow :
70
+
71
+
```typescript
72
+
builder.setOptions(options);
73
+
```
74
+
75
+
### ConfigBuilder
76
+
77
+
```typescript
78
+
classConfigBuilder {
79
+
addSource(...sources:Source[]):ConfigBuilder;
80
+
addEnv(...envs:string[]):ConfigBuilder;
81
+
setOptions(options?:Options):ConfigBuilder;
82
+
build():Config;
83
+
}
84
+
```
85
+
`ConfigBuilder` takes a configuration from the source and creates a new configuration according to the environment. `Env` and `Source` have priority. If priority is not defined, highest priority is added first.
`config` is a container for configuration. `config` is provided by creating a new configuration from the configuration and environment obtained from `source`.
97
+
98
+
### Source
99
+
100
+
```typescript
101
+
interfaceSource {
102
+
export():Map<string, Record<string, unknown>>;
103
+
}
104
+
```
105
+
`Source` defines the source from which to get the configuration. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.
106
+
107
+
You can make custom `Source` and use that.
108
+
109
+
### Sources
110
+
111
+
```typescript
112
+
classSourcesimplementsSource {
113
+
constructor(sources:Source[], options?:Options);
114
+
add(source:Source, priority=-1):Sources;
115
+
export():Map<string, Record<string, unknown>>;
116
+
}
117
+
```
118
+
`Sources` defines the source by merging several sources. Use `add` to add source for new source. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.
`JsonSource` defines the source from JSON. Use `set` to add a configuration for a new environment. Map is returned as the result value of `export`. The key of this map is environment and the value is the configuration when environment.
0 commit comments