qenv/ts/qenv.classes.configvaultadapter.ts
2024-02-09 15:42:00 +01:00

31 lines
890 B
TypeScript

import * as plugins from './qenv.plugins.js';
export class CloudlyAdapter {
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_GetEnvBundle>(
`${parsedUrl.host}/typedrequest`,
'getEnvBundle'
);
const response = await tr.fire({
authorization: parsedUrl.pathname.replace('/', ''),
})
}
}