This repository has been archived on 2026-07-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cloud-reader/mobile/src/api/ebooks.ts
T
crisleo94 22ded87250 feat: implement mobile reader
- implement mobile epub reader
2026-06-20 13:33:44 -05:00

36 lines
1.0 KiB
TypeScript

import { apiClient, getApiBaseUrl } from "./client";
import type {
EBookListItem,
EBookDetail,
TocResponse,
PaginatedResponse,
} from "@cloud-reader/shared";
export const ebooksApi = {
/** List the authenticated user's uploaded e-books */
list() {
return apiClient.get<PaginatedResponse<EBookListItem>>(
"/api/books/ebooks/",
);
},
/** Get e-book detail (metadata, format, progress) */
get(id: number) {
return apiClient.get<EBookDetail>(`/api/books/ebooks/${id}/`);
},
/** Get the table of contents (used as a fallback for chapter navigation) */
getToc(id: number) {
return apiClient.get<TocResponse>(`/api/books/ebooks/${id}/toc/`);
},
/**
* Absolute URL to stream the raw ebook file. The endpoint requires JWT auth,
* so callers download it with an Authorization header (e.g. via
* expo-file-system) rather than handing the URL to a renderer directly.
*/
getFileUrl(id: number): string {
return `${getApiBaseUrl()}/api/books/ebooks/${id}/file/`;
},
};