var express = require("express");
const router = express.Router();
const db = require("../../utils/database");
const dbFuntion = require("../../utils/dbfunctions");
const { response } = require("express");
// const adminMiddleware = require("../../utils/middleware/authMiddleware");

router.post("/deleteUser", (req, res) => {
  const id = req.body.id;
  let dQuer = `delete from finehhdi_fineAD.users where id=${id}`;
  db.query(dQuer, (err, data) => {
    if (err) {
      console.log("error ==>", err);
 
  if(err.code==='ENOTFOUND'){
      res.status(404).json({
        message:"Internet Connection Failed",
        results: 'failed'
      })
      
    }
    else{
      console.log(err);
      res.status(401).json({
        message: "creation failed",
        results: "Failed",
      });
      
    }
  } 
  else {
    
      res.status(200).json({
        message: "Deleted Successfully",
        results: "Success",
      });
    
  }
  });
});

module.exports = router;
