type RouteParams = {
  params: Promise<{
    id: string;
  }>;
};

export async function PATCH(
  request: Request,
  { params }: RouteParams,
): Promise<Response> {
  const { id } = await params;

  const { favorite } = await request.json();

  const response = await fetch(`http://localhost:3001/books/${id}`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ favorite }),
  });

  return response;
}
