feat: add cache entries API and enhance CacheSettings component with server and service worker cache previews
This commit is contained in:
27
src/app/api/komga/cache/entries/route.ts
vendored
Normal file
27
src/app/api/komga/cache/entries/route.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { ServerCacheService } from "@/lib/services/server-cache.service";
|
||||
import { getServerCacheService } from "@/lib/services/server-cache.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const cacheService: ServerCacheService = await getServerCacheService();
|
||||
const entries = await cacheService.getCacheEntries();
|
||||
|
||||
return NextResponse.json({ entries });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération des entrées du cache:", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
code: ERROR_CODES.CACHE.SIZE_FETCH_ERROR,
|
||||
name: "Cache entries fetch error",
|
||||
message: getErrorMessage(ERROR_CODES.CACHE.SIZE_FETCH_ERROR),
|
||||
},
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user