fp/packages/fetchers/src/patchVod.ts

29 lines
833 B
TypeScript

import type { StreamRecord } from "@futureporn/types";
import { configs } from "./config.ts";
export default async function patchVod(stream_id: string, payload: Partial<StreamRecord>): 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()
console.error(body)
throw new Error(`Problem during patchVod. res.status=${res.status}, res.statusText=${res.statusText}`)
}
return
} catch (e) {
console.error(e)
throw e
}
}