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

type Data = {
  name: string
}

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
    const _data = req.body._data;
    if (req.method === 'POST') {
        pool.query("SELECT salt FROM user WHERE login=?", [_data.name], function(err, rows) {
            if (rows.length<1) {
                res.status(200).json({error:'Неверный логин'});
                console.log({error:'Неверный логин'});
            } else {
                res.status(200).json({error:'Неверный пароль'});
                console.log({error:'Неверный пароль'});
            }
         })
      }
}
