feat(appdata): Add support for overwriting keys using the overwriteObject option in AppData
This commit is contained in:
@@ -15,6 +15,7 @@ export interface IAppDataOptions<T = any> {
|
||||
* kvStoreKey: 'MY_ENV_VAR'
|
||||
*/
|
||||
envMapping?: plugins.tsclass.typeFest.PartialDeep<T>;
|
||||
overwriteObject?: plugins.tsclass.typeFest.PartialDeep<T>;
|
||||
}
|
||||
|
||||
export class AppData<T = any> {
|
||||
@@ -175,6 +176,11 @@ export class AppData<T = any> {
|
||||
for (const key in this.options.envMapping) {
|
||||
await processEnvMapping(key as keyof T, this.options.envMapping[key]);
|
||||
}
|
||||
|
||||
for (const key in Object.keys(this.options.overwriteObject)) {
|
||||
console.log(`-> heads up: overwriting key ${key} from options.overwriteObject`);
|
||||
await this.kvStore.writeKey(key as keyof T, this.options.overwriteObject[key]);
|
||||
}
|
||||
}
|
||||
|
||||
this.readyDeferred.resolve();
|
||||
|
Reference in New Issue
Block a user