init
This commit is contained in:
21
app/api/drops/active/route.ts
Normal file
21
app/api/drops/active/route.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import pool from '@/lib/db'
|
||||
|
||||
// GET /api/drops/active - Get the currently active drop (not sold out)
|
||||
export async function GET() {
|
||||
try {
|
||||
const [rows] = await pool.execute(
|
||||
'SELECT * FROM drops WHERE fill < size ORDER BY created_at DESC LIMIT 1'
|
||||
)
|
||||
|
||||
const drops = rows as any[]
|
||||
return NextResponse.json(drops[0] || null)
|
||||
} catch (error) {
|
||||
console.error('Error fetching active drop:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch active drop' },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user