fp/services/bot/src/fetchers/patchVod.ts
CJ_Clippy 614bf16cf8
Some checks failed
ci / build (push) Failing after 1s
combine_video_segments progress
2024-09-03 08:28:39 -08:00

30 lines
862 B
TypeScript

import type { Stream } from "@futureporn/types";
import { configs } from "../config.ts";
import { logger } from "@discordeno/bot";
export default async function patchVod(stream_id: string, payload: Partial<Stream>): Promise<void> {
const url = `${configs.postgrestUrl}/vods?id=eq.${stream_id}`
const fetchOptions = {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${configs.automationUserJwt}`,
'Content-Type': 'application/json',
'Prefer': 'return=headers-only'
},
body: JSON.stringify(payload)
}
try {
const res = await fetch(url, fetchOptions)
if (!res.ok) {
const body = await res.json()
logger.error(body)
throw new Error(`Problem during patchVod. res.status=${res.status}, res.statusText=${res.statusText}`)
}
return
} catch (e) {
logger.error(e)
throw e
}
}