fix: handle missing Komga configuration gracefully by returning an empty array instead of an error in API routes
This commit is contained in:
16
package.json
16
package.json
@@ -17,25 +17,25 @@
|
|||||||
"@prisma/client": "^6.17.1",
|
"@prisma/client": "^6.17.1",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-checkbox": "^1.3.3",
|
"@radix-ui/react-checkbox": "^1.3.3",
|
||||||
"@radix-ui/react-dialog": "1.0.5",
|
"@radix-ui/react-dialog": "1.1.15",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-progress": "^1.1.2",
|
"@radix-ui/react-progress": "^1.1.2",
|
||||||
"@radix-ui/react-select": "^2.1.6",
|
"@radix-ui/react-select": "^2.1.6",
|
||||||
"@radix-ui/react-slot": "1.0.2",
|
"@radix-ui/react-slot": "1.2.3",
|
||||||
"@radix-ui/react-toast": "1.1.5",
|
"@radix-ui/react-toast": "1.2.15",
|
||||||
"@types/bcryptjs": "^3.0.0",
|
"@types/bcryptjs": "^3.0.0",
|
||||||
"bcryptjs": "^3.0.2",
|
"bcryptjs": "^3.0.2",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"framer-motion": "^10.18.0",
|
"framer-motion": "^12.23.24",
|
||||||
"i18next": "^24.2.2",
|
"i18next": "^24.2.2",
|
||||||
"i18next-browser-languagedetector": "^8.0.4",
|
"i18next-browser-languagedetector": "^8.0.4",
|
||||||
"lucide-react": "^0.487.0",
|
"lucide-react": "^0.487.0",
|
||||||
"next": "15.2.0",
|
"next": "15.2.0",
|
||||||
"next-auth": "5.0.0-beta.29",
|
"next-auth": "5.0.0-beta.29",
|
||||||
"next-themes": "0.2.1",
|
"next-themes": "0.2.1",
|
||||||
"react": "18.2.0",
|
"react": "19.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "19.2.0",
|
||||||
"react-i18next": "^15.4.1",
|
"react-i18next": "^15.4.1",
|
||||||
"react-zoom-pan-pinch": "^3.7.0",
|
"react-zoom-pan-pinch": "^3.7.0",
|
||||||
"sharp": "0.33.2",
|
"sharp": "0.33.2",
|
||||||
@@ -46,8 +46,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "24.7.2",
|
"@types/node": "24.7.2",
|
||||||
"@types/react": "18.2.64",
|
"@types/react": "19.2.2",
|
||||||
"@types/react-dom": "18.2.21",
|
"@types/react-dom": "19.2.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
||||||
"@typescript-eslint/parser": "6.21.0",
|
"@typescript-eslint/parser": "6.21.0",
|
||||||
"autoprefixer": "10.4.17",
|
"autoprefixer": "10.4.17",
|
||||||
|
|||||||
1168
pnpm-lock.yaml
generated
1168
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,12 @@ export async function GET() {
|
|||||||
|
|
||||||
return NextResponse.json(validFavoriteIds);
|
return NextResponse.json(validFavoriteIds);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
// Si la config Komga n'existe pas, retourner un tableau vide au lieu d'une erreur
|
||||||
|
if (error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
|
||||||
|
return NextResponse.json([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
console.error("Erreur lors de la récupération des favoris:", error);
|
console.error("Erreur lors de la récupération des favoris:", error);
|
||||||
if (error instanceof AppError) {
|
if (error instanceof AppError) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ export async function GET() {
|
|||||||
const libraries: KomgaLibrary[] = await LibraryService.getLibraries();
|
const libraries: KomgaLibrary[] = await LibraryService.getLibraries();
|
||||||
return NextResponse.json(libraries);
|
return NextResponse.json(libraries);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
// Si la config Komga n'existe pas, retourner un tableau vide au lieu d'une erreur
|
||||||
|
if (error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
|
||||||
|
return NextResponse.json([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
console.error("API Libraries - Erreur:", error);
|
console.error("API Libraries - Erreur:", error);
|
||||||
if (error instanceof AppError) {
|
if (error instanceof AppError) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { ReactElement } from "react";
|
||||||
import { DebugService } from "@/lib/services/debug.service";
|
import { DebugService } from "@/lib/services/debug.service";
|
||||||
|
|
||||||
type PageComponent = (props: any) => Promise<JSX.Element> | JSX.Element;
|
type PageComponent = (props: any) => Promise<ReactElement> | ReactElement;
|
||||||
|
|
||||||
export function withPageTiming(pageName: string, Component: PageComponent) {
|
export function withPageTiming(pageName: string, Component: PageComponent) {
|
||||||
return async function PageWithTiming(props: any) {
|
return async function PageWithTiming(props: any) {
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ export abstract class BaseApiService {
|
|||||||
authHeader: config.authHeader,
|
authHeader: config.authHeader,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof AppError && error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
console.error("Erreur lors de la récupération de la configuration:", error);
|
console.error("Erreur lors de la récupération de la configuration:", error);
|
||||||
throw new AppError(ERROR_CODES.KOMGA.MISSING_CONFIG, {}, error);
|
throw new AppError(ERROR_CODES.KOMGA.MISSING_CONFIG, {}, error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user