fix error server

This commit is contained in:
2025-02-10 12:15:43 +08:00
parent 7cafd9ff79
commit 075d480969
13 changed files with 177 additions and 160 deletions

View File

@@ -3,42 +3,46 @@ import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json({
success: false,
message: "Method not allowed",
if (request.method !== "GET") {
return NextResponse.json(
{
success: false,
message: "Method not allowed",
},
{ status: 405 }
);
}
try {
let fixData;
fixData = await prisma.voting.count({
where: {
Voting_Status: {
name: "Publish",
},
{ status: 405 }
)
}
try {
let fixData;
fixData = await prisma.voting.count({
where: {
Voting_Status: {
name: "Publish",
},
isArsip: true,
}
})
return NextResponse.json({
success: true,
message: 'Success get data voting dashboard',
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error('Error get data voting dashboard >>', error);
NextResponse.json({
success: false,
message: 'Error get data voting dashboard',
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}
isArsip: true,
},
});
return NextResponse.json(
{
success: true,
message: "Success get data voting dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data voting dashboard >>", error);
return NextResponse.json(
{
success: false,
message: "Error get data voting dashboard",
reason: (error as Error).message,
},
{ status: 500 }
);
} finally {
await prisma.$disconnect();
}
}