type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Get Region
* Get a single region mapping.
*/
export async function main(
auth: Cloudflare,
region_code:
| "WNAM"
| "ENAM"
| "WEU"
| "EEU"
| "NSAM"
| "SSAM"
| "OC"
| "ME"
| "NAF"
| "SAF"
| "SAS"
| "SEAS"
| "NEAS",
account_identifier: string
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/load_balancers/regions/${region_code}`
);
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 407 days ago