// 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 {BasicOrder, Order, OrderWithDetails} from "../../server/types/order";
import { db } from "../../server/db/connect";

type Data = {
    row: string,
}

const queryString = "SELECT * FROM stock WHERE status=1";

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