type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Export DNS Records
* You can export your [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this endpoint.
See [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") for more information.
*/
export async function main(auth: Cloudflare, zone_identifier: string) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/dns_records/export`
);
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.text();
}
Submitted by hugo697 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Export DNS Records
* You can export your [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this endpoint.
See [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") for more information.
*/
export async function main(auth: Cloudflare, zone_identifier: string) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/dns_records/export`
);
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.text();
}
Submitted by hugo697 920 days ago