feat: implement DELETE API endpoint for cache invalidation in HomeService and update ClientHomePage to utilize it
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { AuthConfig } from "@/types/auth";
|
||||
import type { CacheType } from "@/types/cache";
|
||||
import { getServerCacheService } from "./server-cache.service";
|
||||
import { ConfigDBService } from "./config-db.service";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
@@ -8,8 +9,8 @@ import type { ServerCacheService } from "./server-cache.service";
|
||||
import { DebugService } from "./debug.service";
|
||||
import { RequestMonitorService } from "./request-monitor.service";
|
||||
import { RequestQueueService } from "./request-queue.service";
|
||||
// Types de cache disponibles
|
||||
export type CacheType = "DEFAULT" | "HOME" | "LIBRARIES" | "SERIES" | "BOOKS" | "IMAGES";
|
||||
|
||||
export type { CacheType };
|
||||
|
||||
interface KomgaRequestInit extends RequestInit {
|
||||
isImage?: boolean;
|
||||
@@ -87,23 +88,9 @@ export abstract class BaseApiService {
|
||||
}
|
||||
|
||||
protected static async resolveWithFallback(url: string): Promise<string> {
|
||||
try {
|
||||
// Essayer de résoudre le DNS d'abord
|
||||
const urlObj = new URL(url);
|
||||
const hostname = urlObj.hostname;
|
||||
|
||||
// Si c'est un nom de domaine, essayer de le résoudre
|
||||
if (!/^\d+\.\d+\.\d+\.\d+$/.test(hostname)) {
|
||||
// Vérifier si le domaine peut être résolu
|
||||
const { lookup } = await import('dns').then(dns => dns.promises);
|
||||
await lookup(hostname);
|
||||
}
|
||||
|
||||
return url;
|
||||
} catch (dnsError) {
|
||||
console.warn(`DNS resolution failed for ${url}, using original URL:`, dnsError);
|
||||
return url;
|
||||
}
|
||||
// DNS resolution is only needed server-side and causes build issues
|
||||
// The fetch API will handle DNS resolution automatically
|
||||
return url;
|
||||
}
|
||||
|
||||
protected static async fetchFromApi<T>(
|
||||
|
||||
@@ -1,28 +1,12 @@
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import type { CacheType } from "./base-api.service";
|
||||
import type { RequestTiming } from "@/types/debug";
|
||||
import { PreferencesService } from "./preferences.service";
|
||||
import { getCurrentUser } from "../auth-utils";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
import { AppError } from "../../utils/errors";
|
||||
|
||||
export interface RequestTiming {
|
||||
url: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
duration: number;
|
||||
timestamp: string;
|
||||
fromCache: boolean;
|
||||
cacheType?: CacheType;
|
||||
mongoAccess?: {
|
||||
operation: string;
|
||||
duration: number;
|
||||
};
|
||||
pageRender?: {
|
||||
page: string;
|
||||
duration: number;
|
||||
};
|
||||
}
|
||||
export type { RequestTiming };
|
||||
|
||||
export class DebugService {
|
||||
private static writeQueues = new Map<string, Promise<void>>();
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import { BaseApiService } from "./base-api.service";
|
||||
import type { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||
import type { LibraryResponse } from "@/types/library";
|
||||
import type { HomeData } from "@/types/home";
|
||||
import { getServerCacheService } from "./server-cache.service";
|
||||
import { ERROR_CODES } from "../../constants/errorCodes";
|
||||
import { AppError } from "../../utils/errors";
|
||||
|
||||
export interface HomeData {
|
||||
ongoing: KomgaSeries[];
|
||||
ongoingBooks: KomgaBook[];
|
||||
recentlyRead: KomgaBook[];
|
||||
onDeck: KomgaBook[];
|
||||
latestSeries: KomgaSeries[];
|
||||
}
|
||||
export type { HomeData };
|
||||
|
||||
export class HomeService extends BaseApiService {
|
||||
static async getHomeData(): Promise<HomeData> {
|
||||
|
||||
Reference in New Issue
Block a user