feat: add logging enhancements by integrating pino and pino-pretty for improved error tracking and debugging across the application
This commit is contained in:
@@ -4,6 +4,7 @@ import { BookService } from "@/lib/services/book.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -39,7 +40,7 @@ export async function GET(
|
||||
headers,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la page:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la page:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BookService } from "@/lib/services/book.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
@@ -29,7 +30,7 @@ export async function PATCH(
|
||||
await BookService.updateReadProgress(bookId, page, completed);
|
||||
return NextResponse.json({ message: "📖 Progression mise à jour avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la mise à jour de la progression:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la mise à jour de la progression:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -65,7 +66,7 @@ export async function DELETE(
|
||||
await BookService.deleteReadProgress(bookId);
|
||||
return NextResponse.json({ message: "🗑️ Progression supprimée avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression de la progression:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la suppression de la progression:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import type { KomgaBookWithPages } from "@/types/komga";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
@@ -18,7 +19,7 @@ export async function GET(
|
||||
|
||||
return NextResponse.json({ ...data, nextBook });
|
||||
} catch (error) {
|
||||
console.error("API Books - Erreur:", error);
|
||||
logger.error({ err: error }, "API Books - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import { HomeService } from "@/lib/services/home.service";
|
||||
import { SeriesService } from "@/lib/services/series.service";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
@@ -30,7 +31,7 @@ export async function POST(
|
||||
|
||||
return NextResponse.json({ message: "🧹 Cache vidé avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression du cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la suppression du cache:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
3
src/app/api/komga/cache/clear/route.ts
vendored
3
src/app/api/komga/cache/clear/route.ts
vendored
@@ -4,6 +4,7 @@ import { getServerCacheService } from "@/lib/services/server-cache.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
@@ -18,7 +19,7 @@ export async function POST() {
|
||||
|
||||
return NextResponse.json({ message: "🧹 Cache vidé avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression du cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la suppression du cache:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
3
src/app/api/komga/cache/entries/route.ts
vendored
3
src/app/api/komga/cache/entries/route.ts
vendored
@@ -3,6 +3,7 @@ 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";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
@@ -11,7 +12,7 @@ export async function GET() {
|
||||
|
||||
return NextResponse.json({ entries });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération des entrées du cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération des entrées du cache");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
5
src/app/api/komga/cache/mode/route.ts
vendored
5
src/app/api/komga/cache/mode/route.ts
vendored
@@ -4,13 +4,14 @@ import { getServerCacheService } from "@/lib/services/server-cache.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const cacheService: ServerCacheService = await getServerCacheService();
|
||||
return NextResponse.json({ mode: cacheService.getCacheMode() });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération du mode de cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération du mode de cache:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
@@ -44,7 +45,7 @@ export async function POST(request: NextRequest) {
|
||||
cacheService.setCacheMode(mode);
|
||||
return NextResponse.json({ mode: cacheService.getCacheMode() });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la mise à jour du mode de cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la mise à jour du mode de cache:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
3
src/app/api/komga/cache/size/route.ts
vendored
3
src/app/api/komga/cache/size/route.ts
vendored
@@ -3,6 +3,7 @@ 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";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
@@ -15,7 +16,7 @@ export async function GET() {
|
||||
mode: cacheService.getCacheMode()
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la taille du cache:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la taille du cache:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import type { KomgaConfig, KomgaConfigData } from "@/types/komga";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function POST(request: NextRequest) {
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la sauvegarde de la configuration:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la sauvegarde de la configuration:");
|
||||
if (error instanceof Error && error.message === "Utilisateur non authentifié") {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -49,7 +50,7 @@ export async function GET() {
|
||||
|
||||
return NextResponse.json(mongoConfig, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la configuration:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la configuration:");
|
||||
if (error instanceof Error) {
|
||||
if (error.message === "Utilisateur non authentifié") {
|
||||
return NextResponse.json(
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
@@ -35,7 +36,7 @@ export async function GET() {
|
||||
return NextResponse.json([]);
|
||||
}
|
||||
}
|
||||
console.error("Erreur lors de la récupération des favoris:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération des favoris:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -67,7 +68,7 @@ export async function POST(request: NextRequest) {
|
||||
await FavoriteService.addToFavorites(seriesId);
|
||||
return NextResponse.json({ message: "⭐️ Série ajoutée aux favoris" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de l'ajout du favori:", error);
|
||||
logger.error({ err: error }, "Erreur lors de l'ajout du favori:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -99,7 +100,7 @@ export async function DELETE(request: NextRequest) {
|
||||
await FavoriteService.removeFromFavorites(seriesId);
|
||||
return NextResponse.json({ message: "💔 Série retirée des favoris" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression du favori:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la suppression du favori:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ import { HomeService } from "@/lib/services/home.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import logger from "@/lib/logger";
|
||||
export const revalidate = 60;
|
||||
|
||||
export async function GET() {
|
||||
@@ -10,7 +11,7 @@ export async function GET() {
|
||||
const data = await HomeService.getHomeData();
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
console.error("API Home - Erreur:", error);
|
||||
logger.error({ err: error }, "API Home - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -41,7 +42,7 @@ export async function DELETE() {
|
||||
await HomeService.invalidateHomeCache();
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("API Home - Erreur lors de l'invalidation du cache:", error);
|
||||
logger.error({ err: error }, "API Home - Erreur lors de l'invalidation du cache:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { findHttpStatus } from "@/utils/image-errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -18,7 +19,7 @@ export async function GET(
|
||||
const response = await BookService.getPage(bookId, parseInt(pageNumber));
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la page du livre:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la page du livre:");
|
||||
|
||||
// Chercher un status HTTP 404 dans la chaîne d'erreurs
|
||||
const httpStatus = findHttpStatus(error);
|
||||
@@ -26,7 +27,7 @@ export async function GET(
|
||||
if (httpStatus === 404) {
|
||||
const { bookId, pageNumber } = await params;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`📷 Page ${pageNumber} not found for book: ${bookId}`);
|
||||
logger.info(`📷 Page ${pageNumber} not found for book: ${bookId}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { findHttpStatus } from "@/utils/image-errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -32,7 +33,7 @@ export async function GET(
|
||||
const response = await BookService.getPageThumbnail(bookId, pageNumber);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la miniature de la page:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la miniature de la page:");
|
||||
|
||||
// Chercher un status HTTP 404 dans la chaîne d'erreurs
|
||||
const httpStatus = findHttpStatus(error);
|
||||
@@ -41,7 +42,7 @@ export async function GET(
|
||||
const { bookId, pageNumber: pageNumberParam } = await params;
|
||||
const pageNumber: number = parseInt(pageNumberParam);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`📷 Page ${pageNumber} thumbnail not found for book: ${bookId}`);
|
||||
logger.info(`📷 Page ${pageNumber} thumbnail not found for book: ${bookId}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { findHttpStatus } from "@/utils/image-errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
@@ -16,7 +17,7 @@ export async function GET(
|
||||
const response = await BookService.getCover(bookId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la miniature du livre:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la miniature du livre:");
|
||||
|
||||
// Chercher un status HTTP 404 dans la chaîne d'erreurs
|
||||
const httpStatus = findHttpStatus(error);
|
||||
@@ -24,7 +25,7 @@ export async function GET(
|
||||
if (httpStatus === 404) {
|
||||
const bookId: string = (await params).bookId;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`📷 Thumbnail not found for book: ${bookId}`);
|
||||
logger.info(`📷 Thumbnail not found for book: ${bookId}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { findHttpStatus } from "@/utils/image-errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -18,7 +19,7 @@ export async function GET(
|
||||
const response = await SeriesService.getCover(seriesId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la couverture de la série:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la couverture de la série:");
|
||||
|
||||
// Chercher un status HTTP 404 dans la chaîne d'erreurs
|
||||
const httpStatus = findHttpStatus(error);
|
||||
@@ -26,7 +27,7 @@ export async function GET(
|
||||
if (httpStatus === 404) {
|
||||
const seriesId: string = (await params).seriesId;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`📷 First page image not found for series: ${seriesId}`);
|
||||
logger.info(`📷 First page image not found for series: ${seriesId}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { findHttpStatus } from "@/utils/image-errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
@@ -15,15 +16,14 @@ export async function GET(
|
||||
const response = await SeriesService.getCover(seriesId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la miniature de la série:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la miniature de la série");
|
||||
|
||||
// Chercher un status HTTP 404 dans la chaîne d'erreurs
|
||||
const httpStatus = findHttpStatus(error);
|
||||
|
||||
if (httpStatus === 404) {
|
||||
const seriesId: string = (await params).seriesId;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`📷 Image not found for series: ${seriesId}`);
|
||||
logger.info(`📷 Image not found for series: ${seriesId}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
@@ -17,7 +18,7 @@ export async function POST(
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("API Library Scan - Erreur:", error);
|
||||
logger.error({ err: error }, "API Library Scan - Erreur");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
export const revalidate = 60;
|
||||
|
||||
const DEFAULT_PAGE_SIZE = 20;
|
||||
@@ -35,7 +36,7 @@ export async function GET(
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("API Library Series - Erreur:", error);
|
||||
logger.error({ err: error }, "API Library Series - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -72,7 +73,7 @@ export async function DELETE(
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("API Library Cache Invalidation - Erreur:", error);
|
||||
logger.error({ err: error }, "API Library Cache Invalidation - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import type { KomgaLibrary } from "@/types/komga";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import logger from "@/lib/logger";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
@@ -17,7 +18,7 @@ export async function GET() {
|
||||
return NextResponse.json([]);
|
||||
}
|
||||
}
|
||||
console.error("API Libraries - Erreur:", error);
|
||||
logger.error({ err: error }, "API Libraries - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BookService } from "@/lib/services/book.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -27,7 +28,7 @@ export async function GET(request: NextRequest) {
|
||||
const bookId = await BookService.getRandomBookFromLibraries(libraryIds);
|
||||
return NextResponse.json({ bookId });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération d'un livre aléatoire:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération d'un livre aléatoire");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
export const revalidate = 60;
|
||||
|
||||
const DEFAULT_PAGE_SIZE = 20;
|
||||
@@ -34,7 +35,7 @@ export async function GET(
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("API Series Books - Erreur:", error);
|
||||
logger.error({ err: error }, "API Series Books - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -74,7 +75,7 @@ export async function DELETE(
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("API Series Cache Invalidation - Erreur:", error);
|
||||
logger.error({ err: error }, "API Series Cache Invalidation - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import { AppError } from "@/utils/errors";
|
||||
import type { KomgaSeries } from "@/types/komga";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
export const revalidate = 60;
|
||||
|
||||
export async function GET(
|
||||
@@ -21,7 +22,7 @@ export async function GET(
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("API Series - Erreur:", error);
|
||||
logger.error({ err: error }, "API Series - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { KomgaLibrary } from "@/types/komga";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
@@ -21,7 +22,7 @@ export async function POST(request: NextRequest) {
|
||||
} trouvée${libraries.length > 1 ? "s" : ""}`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur lors du test de connexion:", error);
|
||||
logger.error({ err: error }, "Erreur lors du test de connexion:");
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
|
||||
@@ -4,13 +4,14 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import type { TTLConfig } from "@/types/komga";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const config: TTLConfig | null = await ConfigDBService.getTTLConfig();
|
||||
return NextResponse.json(config);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la configuration TTL:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la récupération de la configuration TTL");
|
||||
if (error instanceof Error) {
|
||||
if (error.message === getErrorMessage(ERROR_CODES.MIDDLEWARE.UNAUTHORIZED)) {
|
||||
return NextResponse.json(
|
||||
@@ -56,7 +57,7 @@ export async function POST(request: NextRequest) {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la sauvegarde de la configuration TTL:", error);
|
||||
logger.error({ err: error }, "Erreur lors de la sauvegarde de la configuration TTL");
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message === getErrorMessage(ERROR_CODES.MIDDLEWARE.UNAUTHORIZED)
|
||||
|
||||
Reference in New Issue
Block a user