import {SeoRequest} from "./SEOModel.js"; export const AddNewSeoRequest = async (req, res) => { try { let existingSeoRequest = await SeoRequest.findOne(); if (existingSeoRequest) { existingSeoRequest.GoogleTag = req.body.GoogleTag; existingSeoRequest.FacebookPixel = req.body.FacebookPixel; existingSeoRequest.GoogleAnalytics = req.body.GoogleAnalytics; existingSeoRequest.MicrosoftClarity=req.body.MicrosoftClarity; existingSeoRequest = await existingSeoRequest.save(); res.status(200).json({ success: true, seorequest: existingSeoRequest, message: "Seo Request Updated", }); } else { const newSeoRequest = await SeoRequest.create(req.body); res.status(201).json({ success: true, seorequest: newSeoRequest, message: "Seo Request Added", }); } } catch (error) { res.status(500).json({ success: false, message: error.message ? error.message : "Something went Wrong", }); } };