import { pb } from "$lib";
import type { CamerasResponse, StreamsResponse } from "$lib/pocketbase-types";
import type { LayoutLoad } from "./$types";

export const load: LayoutLoad = async ({ params }) => {
	const camera = await pb.collection("cameras").getOne<
		CamerasResponse<{
			streams_via_camera: StreamsResponse[];
		}>
	>(params.id, {
		expand: "streams_via_camera"
	});

	return { camera };
};
