fp/packages/fetchers/src/patchVod.ts

30 lines
885 B
TypeScript
Raw Normal View History

2024-08-27 07:11:24 +00:00
import type { Stream } from "@futureporn/types";
2024-09-06 05:39:08 +00:00
import { configs } from "../../../services/bot/src/config.ts";
2024-08-27 07:11:24 +00:00
import { logger } from "@discordeno/bot";
2024-09-03 16:28:39 +00:00
export default async function patchVod(stream_id: string, payload: Partial<Stream>): Promise<void> {
const url = `${configs.postgrestUrl}/vods?id=eq.${stream_id}`
2024-08-27 07:11:24 +00:00
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)
2024-09-03 16:28:39 +00:00
throw new Error(`Problem during patchVod. res.status=${res.status}, res.statusText=${res.statusText}`)
2024-08-27 07:11:24 +00:00
}
return
} catch (e) {
logger.error(e)
throw e
}
}