initial commit

This commit is contained in:
Daniil
2026-05-14 02:23:02 +03:00
commit b8b8247ff3
34 changed files with 3297 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
type WebhookPayload = {
status: "RUNNING" | "DONE" | "FAILED";
progress_pct: number;
current_message: string;
output_data?: { output_path: string };
error_message?: string;
started_at?: string;
finished_at?: string;
};
const WEBHOOK_TIMEOUT_MS = 10_000;
export async function sendWebhook(
callbackUrl: string,
payload: WebhookPayload,
): Promise<boolean> {
try {
const resp = await fetch(callbackUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(WEBHOOK_TIMEOUT_MS),
});
if (!resp.ok) {
const responseBody = await resp.text().catch(() => "");
console.error(
`Webhook POST to ${callbackUrl} returned ${resp.status}: ${resp.statusText}${responseBody ? `\n${responseBody.slice(0, 1000)}` : ""}`,
);
return false;
}
return true;
} catch (err) {
console.error(`Webhook POST to ${callbackUrl} failed:`, err);
return false;
}
}