feat: initial commit

This commit is contained in:
oxypomme
2025-12-30 19:52:07 +01:00
commit 6514dc165b
10 changed files with 372 additions and 0 deletions

59
lib/komga.ts Normal file
View File

@@ -0,0 +1,59 @@
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<Record<string, any>[]> => {
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<Record<string, any>[]> => {
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<string, unknown>
): Promise<void> =>
komga(`/v1/books/${id}/metadata`, {
method: 'PATCH',
body,
});