feat: implement DELETE API endpoints for cache invalidation in libraries and series, updating ClientLibraryPage and ClientSeriesPage to utilize these endpoints
This commit is contained in:
@@ -54,3 +54,40 @@ export async function GET(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function DELETE(
|
||||||
|
request: NextRequest,
|
||||||
|
{ params }: { params: Promise<{ libraryId: string }> }
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const libraryId: string = (await params).libraryId;
|
||||||
|
|
||||||
|
await LibraryService.invalidateLibrarySeriesCache(libraryId);
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("API Library Cache Invalidation - Erreur:", error);
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
code: error.code,
|
||||||
|
name: "Cache invalidation error",
|
||||||
|
message: getErrorMessage(error.code),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
code: ERROR_CODES.CACHE.DELETE_ERROR,
|
||||||
|
name: "Cache invalidation error",
|
||||||
|
message: getErrorMessage(ERROR_CODES.CACHE.DELETE_ERROR),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,3 +53,43 @@ export async function GET(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function DELETE(
|
||||||
|
request: NextRequest,
|
||||||
|
{ params }: { params: Promise<{ seriesId: string }> }
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const seriesId: string = (await params).seriesId;
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
SeriesService.invalidateSeriesBooksCache(seriesId),
|
||||||
|
SeriesService.invalidateSeriesCache(seriesId)
|
||||||
|
]);
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("API Series Cache Invalidation - Erreur:", error);
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
code: error.code,
|
||||||
|
name: "Cache invalidation error",
|
||||||
|
message: getErrorMessage(error.code),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: {
|
||||||
|
code: ERROR_CODES.CACHE.DELETE_ERROR,
|
||||||
|
name: "Cache invalidation error",
|
||||||
|
message: getErrorMessage(ERROR_CODES.CACHE.DELETE_ERROR),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { RefreshButton } from "@/components/library/RefreshButton";
|
|||||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||||
import { useTranslate } from "@/hooks/useTranslate";
|
import { useTranslate } from "@/hooks/useTranslate";
|
||||||
import { OptimizedSkeleton } from "@/components/skeletons/OptimizedSkeletons";
|
import { OptimizedSkeleton } from "@/components/skeletons/OptimizedSkeletons";
|
||||||
import { LibraryService } from "@/lib/services/library.service";
|
|
||||||
import type { LibraryResponse } from "@/types/library";
|
import type { LibraryResponse } from "@/types/library";
|
||||||
import type { KomgaSeries, KomgaLibrary } from "@/types/komga";
|
import type { KomgaSeries, KomgaLibrary } from "@/types/komga";
|
||||||
import type { UserPreferences } from "@/types/preferences";
|
import type { UserPreferences } from "@/types/preferences";
|
||||||
@@ -77,7 +76,14 @@ export function ClientLibraryPage({
|
|||||||
|
|
||||||
const handleRefresh = async (libraryId: string) => {
|
const handleRefresh = async (libraryId: string) => {
|
||||||
try {
|
try {
|
||||||
await LibraryService.invalidateLibrarySeriesCache(libraryId);
|
// Invalidate cache via API
|
||||||
|
const cacheResponse = await fetch(`/api/komga/libraries/${libraryId}/series`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!cacheResponse.ok) {
|
||||||
|
throw new Error("Error invalidating cache");
|
||||||
|
}
|
||||||
|
|
||||||
// Recharger les données
|
// Recharger les données
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { PaginatedBookGrid } from "@/components/series/PaginatedBookGrid";
|
import { PaginatedBookGrid } from "@/components/series/PaginatedBookGrid";
|
||||||
import { SeriesHeader } from "@/components/series/SeriesHeader";
|
import { SeriesHeader } from "@/components/series/SeriesHeader";
|
||||||
import { SeriesService } from "@/lib/services/series.service";
|
|
||||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||||
import { OptimizedSkeleton } from "@/components/skeletons/OptimizedSkeletons";
|
import { OptimizedSkeleton } from "@/components/skeletons/OptimizedSkeletons";
|
||||||
import type { LibraryResponse } from "@/types/library";
|
import type { LibraryResponse } from "@/types/library";
|
||||||
@@ -70,8 +69,14 @@ export function ClientSeriesPage({
|
|||||||
|
|
||||||
const handleRefresh = async (seriesId: string) => {
|
const handleRefresh = async (seriesId: string) => {
|
||||||
try {
|
try {
|
||||||
await SeriesService.invalidateSeriesBooksCache(seriesId);
|
// Invalidate cache via API
|
||||||
await SeriesService.invalidateSeriesCache(seriesId);
|
const cacheResponse = await fetch(`/api/komga/series/${seriesId}/books`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!cacheResponse.ok) {
|
||||||
|
throw new Error("Erreur lors de l'invalidation du cache");
|
||||||
|
}
|
||||||
|
|
||||||
// Recharger les données
|
// Recharger les données
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
|
|||||||
Reference in New Issue
Block a user