Server IP : 162.213.251.212 / Your IP : 3.145.64.2 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/allssztx/needapair.com/routes/ |
Upload File : |
const express = require('express') const User = require('../schema/User') const Certificate = require('../schema/Certificate') const ECard = require('../schema/E-Card') const router = express.Router() router.post('/update-customer', async (req, res) => { try { const { customerid, credits, role, status } = req.body console.log("req.body", req.body) console.log("customerid", customerid) const customer = await User.findById(customerid) console.log("customer", customer) customer.credits = credits customer.role = role customer.status = status console.log(customer) await customer.save() // return console.log(req.body) return res.status(200).json({ message: `Customer Modified Successfully...!!!` }) } catch (error) { console.log(error) return res.status(503).json({ message: error.message }) } }) router.post('/delete-user', async (req, res) => { try { const { id } = req.body await User.findByIdAndDelete(id) return res.status(200).json({ message: `User Deleted Successfully!` }) } catch (error) { console.log(error) return res.status(200).json({ error: error.message }) } }) router.post('/fetch-items', async (req, res) => { try { const { id } = req.body console.log(id) const certificates = await Certificate.find({ $or: [ { sender: id }, { receiver: id }, ] }).populate('sender').populate('receiver').sort({ createdAt: -1 }) const cards = await ECard.find({ $or: [ { sender: id }, { receiver: id, sent: true }, ], }).populate('sender').populate('receiver').sort({ createdAt: -1 }) return res.status(200).json({ cards, certificates }) } catch (error) { console.log(error) return res.status(200).json({ error: error.message }) } }) module.exports = router;