import {bd} from "@/lib/bd";
import {NextResponse} from "next/server";

export async function GET(request: Request){
    const {searchParams} = new URL(request.url)
    const platform = searchParams.get('platform') || 'pc';
    try {
        const [rows] = await bd.query(
            `SELECT id, title, image_url, platform FROM games WHERE platform = ?`,
            [platform]
        )
        return NextResponse.json(rows)
    }catch (error){
        console.error("DB error", error)
    }
}