31 lines
900 B
TypeScript
31 lines
900 B
TypeScript
|
import * as plugins from './qenv.plugins.js';
|
||
|
|
||
|
export class ConfigVaultAdapter {
|
||
|
public configVaultUrl: string;
|
||
|
|
||
|
constructor(configVaultUrl?: string) {
|
||
|
this.configVaultUrl = configVaultUrl;
|
||
|
}
|
||
|
|
||
|
public async getConfigBundle(): Promise<plugins.configvaultInterfaces.data.IConfigBundle> {
|
||
|
if (this.configVaultUrl) {
|
||
|
console.log(`ConfigVault specified through constructor`)
|
||
|
} else if (process.env['CONFIGVAULT_URL']) {
|
||
|
this.configVaultUrl = process.env['CONFIGVAULT_URL'];
|
||
|
} else {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
const parsedUrl = new URL(this.configVaultUrl);
|
||
|
|
||
|
const tr =
|
||
|
new plugins.typedrequest.TypedRequest<plugins.configvaultInterfaces.requests.IReq_GetConfigBundle>(
|
||
|
`${parsedUrl.host}/typedrequest`,
|
||
|
'getConfigBundle'
|
||
|
);
|
||
|
const response = await tr.fire({
|
||
|
authorization: parsedUrl.pathname.replace('/', ''),
|
||
|
})
|
||
|
}
|
||
|
}
|