import {getUserByEmailServices} from "../services/users.services.js"; export async function doUserAlreadyExists(req,res,next){ const email = req.body.email; const request = await getUserByEmailServices(email); if (request.rows && request.rows.length > 0) { return res.status(409).json({ error: 409, message: `Email already exists`, }) } next(); } export async function doUserExists(req,res,next){ console.log(req.body); const email = req.body.email; const request = await getUserByEmailServices(email); if (request.rows && request.rows.length > 0) { next() } else { return res.json({ error: 401, message: 'Bad Credentials' }) } }