import { getRecording } from "$lib/services";
import type { Recording } from "$lib/types";

export async function load({ url, fetch, cookies }) {
  const recordingId = url.searchParams.get("recording");
  const token = cookies.get("session_token") || "";

  let recording: Recording | null = null;
  if (recordingId) {
    recording = await getRecording(recordingId, fetch, token).catch(() => null);
  }

  return { recording };
}
