30 lines
885 B
TypeScript
30 lines
885 B
TypeScript
|
import type { Stream } from "@futureporn/types";
|
||
|
import { configs } from "../../../services/bot/src/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
|
||
|
}
|
||
|
}
|
||
|
|