import { EndpointFactory } from '$lib/api/endpoints';
import type { TodoItem } from '$lib/api/types';

/** @type {import('./$types').PageLoad} */
export async function load({ fetch, params }) {

  let endpointFactory = new EndpointFactory(fetch);
  let readTodoEndpoint = endpointFactory.createReadTodoEndpoint(params.todo);

  return {
    endpointFactory: endpointFactory,
    todo: readTodoEndpoint.call(),
  };
}

export interface TodoDetailPage {
  endpointFactory: EndpointFactory,
  todo: TodoItem
}
