type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Set Account Custom Nameserver Related Zone Metadata
* Set metadata for account-level custom nameservers on a zone.
If you would like new zones in the account to use account custom nameservers by default, use PUT /accounts/:identifier to set the account setting use_account_custom_ns_by_default to true.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: { enabled?: boolean; ns_set?: number; [k: string]: unknown }
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_ns`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Set Account Custom Nameserver Related Zone Metadata
* Set metadata for account-level custom nameservers on a zone.
If you would like new zones in the account to use account custom nameservers by default, use PUT /accounts/:identifier to set the account setting use_account_custom_ns_by_default to true.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: { enabled?: boolean; ns_set?: number; [k: string]: unknown }
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_ns`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 920 days ago