data auto

This commit is contained in:
2025-02-10 17:53:13 +08:00
parent 7445e8bb3a
commit 1df244402b
8 changed files with 110 additions and 112 deletions

View File

@@ -2,43 +2,31 @@ import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: {
params: { status: string }
}) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json({
success: false,
message: "Method not allowed",
},
{ status: 405 }
)
}
try {
let fixData;
fixData = await prisma.forum_Posting.count({
where: {
isActive: true,
}
})
export async function GET() {
try {
const fixData = await prisma.forum_Posting.count({
where: {
isActive: true,
},
});
return NextResponse.json({
success: true,
message: "Success get data forum dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data forum dashboard", error);
return NextResponse.json({
success: false,
message: "Error get data forum dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}
return NextResponse.json(
{
success: true,
message: "Success get data forum dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data forum dashboard", error);
return NextResponse.json(
{
success: false,
message: "Error get data forum dashboard",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}