feat : File caching option

This commit is contained in:
Julien Froidefond
2025-02-19 16:33:21 +01:00
parent a5fd165200
commit aed35ce2b9
9 changed files with 445 additions and 55 deletions

23
src/app/api/komga/cache/mode/route.ts vendored Normal file
View File

@@ -0,0 +1,23 @@
import { NextResponse } from "next/server";
import { serverCacheService } from "@/lib/services/server-cache.service";
export async function GET() {
return NextResponse.json({ mode: serverCacheService.getCacheMode() });
}
export async function POST(request: Request) {
try {
const { mode } = await request.json();
if (mode !== "file" && mode !== "memory") {
return NextResponse.json(
{ error: "Invalid mode. Must be 'file' or 'memory'" },
{ status: 400 }
);
}
serverCacheService.setCacheMode(mode);
return NextResponse.json({ mode: serverCacheService.getCacheMode() });
} catch (error) {
return NextResponse.json({ error: "Invalid request" }, { status: 400 });
}
}