refactor: remove unused home GET API route
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
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";
|
||||
|
||||
// Cache handled in service via fetchFromApi options
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const data = await HomeService.getHomeData();
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
logger.error({ err: error }, "API Home - Erreur:");
|
||||
if (error instanceof AppError) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
code: error.code,
|
||||
name: "Home data fetch error",
|
||||
message: getErrorMessage(error.code),
|
||||
},
|
||||
},
|
||||
{ status: error.code === ERROR_CODES.KOMGA.MISSING_CONFIG ? 404 : 500 }
|
||||
);
|
||||
}
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
code: ERROR_CODES.KOMGA.SERVER_UNREACHABLE,
|
||||
name: "Home data fetch error",
|
||||
message: getErrorMessage(ERROR_CODES.KOMGA.SERVER_UNREACHABLE),
|
||||
},
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user