// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { OkPacket, QueryError, RowDataPacket } from "mysql2";
import type { NextApiRequest, NextApiResponse } from 'next';
import { pool } from "../../server/db/connect";

type Data = {
    row: string,
}

const queryString = "SELECT products.id, products.title, description, type_pizza.img_trad FROM products, type_pizza WHERE products.status=1 and products.type='pizza' and type_pizza.id_products=products.id and type_pizza.size=40";

export default function handler(
    req: NextApiRequest,
    res: NextApiResponse<Data>)
    {
        pool.query(
            queryString,
            (err: QueryError, rows: RowDataPacket[0]) => {
                res.status(200).json(rows);
            }
        );
    };