refacto: servercomponent and first route for config

This commit is contained in:
Julien Froidefond
2025-02-14 12:51:03 +01:00
parent e3ad1690c5
commit bd652fc1ff
7 changed files with 62 additions and 137 deletions

View File

@@ -27,10 +27,11 @@ export class LibraryService extends BaseApiService {
): Promise<LibraryResponse<Series>> {
try {
const config = await this.getKomgaConfig();
const url = this.buildUrl(config, `libraries/${libraryId}/series`, {
const url = this.buildUrl(config, "series", {
library_id: libraryId,
page: page.toString(),
size: size.toString(),
...(unreadOnly && { read_status: "UNREAD" }),
...(unreadOnly && { read_status: "UNREAD,IN_PROGRESS" }),
});
const headers = this.getAuthHeaders(config);

View File

@@ -1,18 +1,17 @@
import { BaseApiService } from "./base-api.service";
import { Series } from "@/types/series";
import { LibraryResponse } from "@/types/library";
import { KomgaBook } from "@/types/komga";
import { KomgaBook, KomgaSeries } from "@/types/komga";
export class SeriesService extends BaseApiService {
static async getSeries(seriesId: string): Promise<Series> {
static async getSeries(seriesId: string): Promise<KomgaSeries> {
try {
const config = await this.getKomgaConfig();
const url = this.buildUrl(config, `series/${seriesId}`);
const headers = this.getAuthHeaders(config);
return this.fetchWithCache<Series>(
return this.fetchWithCache<KomgaSeries>(
`series-${seriesId}`,
async () => this.fetchFromApi<Series>(url, headers),
async () => this.fetchFromApi<KomgaSeries>(url, headers),
"SERIES"
);
} catch (error) {