fix(start supporting workers again): update

This commit is contained in:
2024-06-17 01:36:39 +02:00
parent 902ca30529
commit b0f8d1e4d0
7 changed files with 83 additions and 24 deletions

View File

@@ -8,7 +8,7 @@ import { ZoneManager } from './cloudflare.classes.zonemanager.js';
export class CloudflareAccount {
private authToken: string;
private accountIdentifier: string;
public preselectedAccountId: string;
public workerManager = new WorkerManager(this);
public zoneManager = new ZoneManager(this);
@@ -26,7 +26,29 @@ export class CloudflareAccount {
});
}
public async preselectAccountByName(nameArg: string) {
const accounts = await this.convenience.listAccounts();
const account = accounts.find((accountArg) => {
return accountArg.name === nameArg;
});
if (account) {
this.preselectedAccountId = account.id;
} else {
throw new Error(`account with name ${nameArg} not found`);
}
}
public convenience = {
/**
* listAccounts
*/
listAccounts: async () => {
const accounts: plugins.ICloudflareTypes['Account'][] = [];
for await (const account of this.apiAccount.accounts.list()) {
accounts.push(account as interfaces.ICloudflareApiAccountObject);
}
return accounts;
},
/**
* gets a zone id of a domain from cloudflare
* @param domainName