This commit is contained in:
root
2025-12-20 22:05:21 +01:00
parent e1a0966dee
commit f2c3b04a88
10 changed files with 1134 additions and 28 deletions

19
app/api/buyers/route.ts Normal file
View File

@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from 'next/server'
import pool from '@/lib/db'
// GET /api/buyers - Get all buyers
export async function GET(request: NextRequest) {
try {
const [rows] = await pool.execute(
'SELECT id, username, email, created_at FROM buyers ORDER BY created_at DESC'
)
return NextResponse.json(rows)
} catch (error) {
console.error('Error fetching buyers:', error)
return NextResponse.json(
{ error: 'Failed to fetch buyers' },
{ status: 500 }
)
}
}