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