type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Create waiting room
* Creates a new waiting room.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: {
additional_routes?: {
host?: string;
path?: string;
[k: string]: unknown;
}[];
cookie_attributes?: {
samesite?: "auto" | "lax" | "none" | "strict";
secure?: "auto" | "always" | "never";
[k: string]: unknown;
};
cookie_suffix?: string;
custom_page_html?: string;
default_template_language?:
| "en-US"
| "es-ES"
| "de-DE"
| "fr-FR"
| "it-IT"
| "ja-JP"
| "ko-KR"
| "pt-BR"
| "zh-CN"
| "zh-TW"
| "nl-NL"
| "pl-PL"
| "id-ID"
| "tr-TR"
| "ar-EG"
| "ru-RU"
| "fa-IR";
description?: string;
disable_session_renewal?: boolean;
host: string;
json_response_enabled?: boolean;
name: string;
new_users_per_minute: number;
path?: string;
queue_all?: boolean;
queueing_method?: "fifo" | "random" | "passthrough" | "reject";
queueing_status_code?: 200 | 202 | 429;
session_duration?: number;
suspended?: boolean;
total_active_users: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/waiting_rooms`
);
const response = await fetch(url, {
method: "POST",
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;
};
/**
* Create waiting room
* Creates a new waiting room.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: {
additional_routes?: {
host?: string;
path?: string;
[k: string]: unknown;
}[];
cookie_attributes?: {
samesite?: "auto" | "lax" | "none" | "strict";
secure?: "auto" | "always" | "never";
[k: string]: unknown;
};
cookie_suffix?: string;
custom_page_html?: string;
default_template_language?:
| "en-US"
| "es-ES"
| "de-DE"
| "fr-FR"
| "it-IT"
| "ja-JP"
| "ko-KR"
| "pt-BR"
| "zh-CN"
| "zh-TW"
| "nl-NL"
| "pl-PL"
| "id-ID"
| "tr-TR"
| "ar-EG"
| "ru-RU"
| "fa-IR";
description?: string;
disable_session_renewal?: boolean;
host: string;
json_response_enabled?: boolean;
name: string;
new_users_per_minute: number;
path?: string;
queue_all?: boolean;
queueing_method?: "fifo" | "random" | "passthrough" | "reject";
queueing_status_code?: 200 | 202 | 429;
session_duration?: number;
suspended?: boolean;
total_active_users: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/waiting_rooms`
);
const response = await fetch(url, {
method: "POST",
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