Usulan Commit Message

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
This commit is contained in:
2026-03-05 14:28:45 +08:00
parent a6c9182a01
commit 3e6c94d77f
33 changed files with 312 additions and 128 deletions

View File

@@ -1,8 +1,11 @@
# ==============================
# Database
# ==============================
# Tambahkan connection_limit dan pool_timeout untuk mencegah connection exhaustion
DATABASE_URL="postgresql://user:password@localhost:5432/dbname?connection_limit=10&pool_timeout=20"
# Connection pool settings untuk mencegah connection exhaustion:
# - connection_limit=10: Maksimal 10 koneksi per Prisma Client instance
# - pool_timeout=20: Timeout menunggu koneksi tersedia (detik)
# - connect_timeout=10: Timeout untuk membuat koneksi baru (detik)
DATABASE_URL="postgresql://user:password@localhost:5432/dbname?connection_limit=10&pool_timeout=20&connect_timeout=10"
# ==============================
# Auth / Session