fix: Implementasi retry mechanism dan error handling untuk database connections Deskripsi: Menambahkan withRetry wrapper pada berbagai API routes untuk menangani transient database errors dan meningkatkan reliabilitas koneksi Memperbaiki error handling pada notification, authentication, dan user validation endpoints dengan response 503 untuk database connection errors Update prisma.ts dengan konfigurasi logging yang lebih baik dan datasources configuration Menambahkan validasi input parameters pada beberapa endpoints Update dokumentasi QWEN.md dengan commit message format dan comment standards Update .env.example dengan connection pool settings yang lebih lengkap File yang diubah: src/lib/prisma.ts — Konfigurasi Prisma client & logging src/app/api/admin/notifikasi/count/route.tsx src/app/api/auth/mobile-login/route.ts src/app/api/mobile/notification/[id]/route.ts src/app/api/user-validate/route.ts Dan 27 file API routes lainnya (penerapan withRetry secara konsisten) QWEN.md — Dokumentasi commit & comment standards .env.example — Database connection pool configuration ### No Issue
47 lines
960 B
TypeScript
47 lines
960 B
TypeScript
import { prisma } from "@/lib";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
context: { params: { id: string } }
|
|
) {
|
|
const method = request.method;
|
|
if (method !== "GET") {
|
|
return NextResponse.json(
|
|
{ success: false, message: "Method not allowed" },
|
|
{ status: 405 }
|
|
);
|
|
}
|
|
|
|
try {
|
|
let fixData;
|
|
const { id } = context.params;
|
|
|
|
fixData = await prisma.event.findUnique({
|
|
where: {
|
|
id: id,
|
|
},
|
|
include: {
|
|
Author: {
|
|
include: {
|
|
Profile: true,
|
|
},
|
|
},
|
|
EventMaster_TipeAcara: true,
|
|
EventMaster_Status: true,
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: "Berhasil mendapatkan data",
|
|
data: fixData,
|
|
});
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ success: false, message: "Gagal mendapatkan data" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|