import { ofetch } from 'ofetch'; export const komga = ofetch.create({ baseURL: new URL('/api', Deno.env.get('BASE_URL')!).href, headers: { 'X-API-Key': Deno.env.get('API_KEY')!, }, }); export const fetchLibraryMangas = async ( libraryId: string ): Promise[]> => { const { content } = await komga('/v1/series/list', { method: 'POST', query: { unpaged: true, }, body: { condition: { libraryId: { operator: 'is', value: libraryId, }, }, }, }); return content; }; export const fetchMangaChapters = async ( seriesId: string ): Promise[]> => { const { content } = await komga('/v1/books/list', { method: 'POST', query: { unpaged: true, }, body: { condition: { seriesId: { operator: 'is', value: seriesId, }, }, }, }); return content; }; export const updateMetadata = ( id: string, body: Record ): Promise => komga(`/v1/books/${id}/metadata`, { method: 'PATCH', body, });