type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Get an account entry point ruleset
* Fetches the latest version of the account entry point ruleset for a given phase.
*/
export async function main(
auth: Cloudflare,
ruleset_phase:
| "ddos_l4"
| "ddos_l7"
| "http_config_settings"
| "http_custom_errors"
| "http_log_custom_fields"
| "http_ratelimit"
| "http_request_cache_settings"
| "http_request_dynamic_redirect"
| "http_request_firewall_custom"
| "http_request_firewall_managed"
| "http_request_late_transform"
| "http_request_origin"
| "http_request_redirect"
| "http_request_sanitize"
| "http_request_sbfm"
| "http_request_select_configuration"
| "http_request_transform"
| "http_response_compression"
| "http_response_firewall_managed"
| "http_response_headers_transform"
| "magic_transit"
| "magic_transit_ids_managed"
| "magic_transit_managed",
account_id: string
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_id}/rulesets/phases/${ruleset_phase}/entrypoint`
);
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 86 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Get an account entry point ruleset
* Fetches the latest version of the account entry point ruleset for a given phase.
*/
export async function main(
auth: Cloudflare,
ruleset_phase:
| "ddos_l4"
| "ddos_l7"
| "http_config_settings"
| "http_custom_errors"
| "http_log_custom_fields"
| "http_ratelimit"
| "http_request_cache_settings"
| "http_request_dynamic_redirect"
| "http_request_firewall_custom"
| "http_request_firewall_managed"
| "http_request_late_transform"
| "http_request_origin"
| "http_request_redirect"
| "http_request_sanitize"
| "http_request_sbfm"
| "http_request_select_configuration"
| "http_request_transform"
| "http_response_compression"
| "http_response_firewall_managed"
| "http_response_headers_transform"
| "magic_transit"
| "magic_transit_ids_managed"
| "magic_transit_managed",
account_id: string
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_id}/rulesets/phases/${ruleset_phase}/entrypoint`
);
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 624 days ago