refacto: errors in apis

This commit is contained in:
Julien Froidefond
2025-02-25 08:40:06 +01:00
parent bf6fa0a71d
commit a690a5af6f
29 changed files with 720 additions and 109 deletions

View File

@@ -1,8 +1,23 @@
import { NextResponse } from "next/server";
import { getServerCacheService } from "@/lib/services/server-cache.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { ERROR_MESSAGES } from "@/constants/errorMessages";
export async function POST() {
const cacheService = await getServerCacheService();
cacheService.clear();
return NextResponse.json({ message: "Cache cleared" });
try {
const cacheService = 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,
message: ERROR_MESSAGES[ERROR_CODES.CACHE.CLEAR_ERROR],
},
},
{ status: 500 }
);
}
}