feat: initial commit
This commit is contained in:
59
lib/komga.ts
Normal file
59
lib/komga.ts
Normal 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,
|
||||
});
|
||||
Reference in New Issue
Block a user