qenv/ts/qenv.classes.configvaultadapter.ts

31 lines
890 B
TypeScript
Raw Normal View History

2023-08-09 15:47:20 +00:00
import * as plugins from './qenv.plugins.js';
2024-02-09 14:42:00 +00:00
export class CloudlyAdapter {
2023-08-09 15:47:20 +00:00
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 =
2023-10-20 15:21:51 +00:00
new plugins.typedrequest.TypedRequest<plugins.configvaultInterfaces.requests.IReq_GetEnvBundle>(
2023-08-09 15:47:20 +00:00
`${parsedUrl.host}/typedrequest`,
2023-10-20 15:21:51 +00:00
'getEnvBundle'
2023-08-09 15:47:20 +00:00
);
const response = await tr.fire({
authorization: parsedUrl.pathname.replace('/', ''),
})
}
}