Archived
- Add mobile/ directory with Expo React Native project - Create API client with JWT auth and token refresh using AsyncStorage - Implement AuthContext for login/register/logout flow - Add screens: Login, Register, Library, Search, Settings - Set up React Navigation with AuthStack and MainTabs - Create packages/shared/ with shared types and utilities - Add shared validation utilities (email, password strength) - Update root package.json workspaces to include mobile + shared - Add spec document docs/backend/009-expo-integration.md
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { apiClient } from "./client";
|
|
import type {
|
|
EBookListItem,
|
|
EBookDetail,
|
|
ReadingProgress,
|
|
ReadingSettings,
|
|
TocResponse,
|
|
ContentResponse,
|
|
PaginatedResponse,
|
|
} from "@cloud-reader/shared";
|
|
|
|
export const ebooksApi = {
|
|
/** List uploaded e-books */
|
|
list() {
|
|
return apiClient.get<PaginatedResponse<EBookListItem>>("/api/ebooks/");
|
|
},
|
|
|
|
/** Get e-book detail */
|
|
get(id: number) {
|
|
return apiClient.get<EBookDetail>(`/api/ebooks/${id}/`);
|
|
},
|
|
|
|
/** Get table of contents */
|
|
getToc(id: number) {
|
|
return apiClient.get<TocResponse>(`/api/ebooks/${id}/toc/`);
|
|
},
|
|
|
|
/** Get page content */
|
|
getContent(id: number, page: number) {
|
|
return apiClient.get<ContentResponse>(
|
|
`/api/ebooks/${id}/content/?page=${page}`,
|
|
);
|
|
},
|
|
|
|
/** Update reading progress */
|
|
updateProgress(id: number, data: Partial<ReadingProgress>) {
|
|
return apiClient.patch<ReadingProgress>(
|
|
`/api/ebooks/${id}/progress/`,
|
|
data,
|
|
);
|
|
},
|
|
|
|
/** Get or update reading settings */
|
|
getSettings(id: number) {
|
|
return apiClient.get<ReadingSettings>(`/api/ebooks/${id}/settings/`);
|
|
},
|
|
|
|
updateSettings(id: number, data: Partial<ReadingSettings>) {
|
|
return apiClient.patch<ReadingSettings>(
|
|
`/api/ebooks/${id}/settings/`,
|
|
data,
|
|
);
|
|
},
|
|
}; |