import type { APIResponse, Vod } from "../types.ts"; import { API_URL, AuthError } from "./client.ts"; const getVods = async (): Promise => { const response = await fetch(API_URL + '/api/v1/vods', { credentials: 'include' }); if (!response.ok) { const errorResult: APIResponse = await response.json(); throw new Error(`Failed to fetch vods: ${errorResult.message}`); } const result: APIResponse = await response.json(); return result.data; }; const getVodById = async (id: string): Promise => { const response = await fetch(API_URL + `/api/v1/vods/${id}`, { credentials: 'include' }); if (!response.ok) { if (response.status === 401 || response.status === 403) throw new AuthError(); throw new Error(`Failed to fetch vod: ${response.status}`); } const result: APIResponse = await response.json(); return result.data; }; // URL for the raw media stream. The