import api from "./client"; import type { Book, PaginatedResponse } from "@cloud-reader/shared"; export function fetchBooks( page = 1, pageSize = 20, ): Promise> { return api .get>("/api/books/", { params: { page, page_size: pageSize }, }) .then((res) => res.data); } export function fetchBook(id: string): Promise { return api.get(`/api/books/${id}/`).then((res) => res.data); } export function searchBooks( query: string, ): Promise> { return api .get>("/api/books/search/", { params: { q: query }, }) .then((res) => res.data); } export function deleteBook(id: string): Promise { return api.delete(`/api/books/${id}/`).then(() => {}); }