Files
stripstream/src/app/api/komga/cache/clear/route.ts
Julien Froidefond a4b521fe2e fix: lint type import
2025-03-02 14:02:23 +01:00

26 lines
872 B
TypeScript

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 POST() {
try {
const cacheService: ServerCacheService = await getServerCacheService();
cacheService.clear();
return NextResponse.json({ message: "🧹 Cache vidé avec succès" });
} catch (error) {
console.error("Erreur lors de la suppression du cache:", error);
return NextResponse.json(
{
error: {
code: ERROR_CODES.CACHE.CLEAR_ERROR,
name: "Cache clear error",
message: getErrorMessage(ERROR_CODES.CACHE.CLEAR_ERROR),
},
},
{ status: 500 }
);
}
}