seo api added
This commit is contained in:
parent
fa76a3e0ab
commit
468238a28f
4
app.js
4
app.js
@ -157,6 +157,8 @@ import SpecialtiesRouter from "./resources/Specialties/SpecialtiesRoute.js";
|
|||||||
import ShippingAddressRoute from "./resources/ShippingAddresses/ShippingAddressRoute.js";
|
import ShippingAddressRoute from "./resources/ShippingAddresses/ShippingAddressRoute.js";
|
||||||
import stripeRoute from "./resources/StripePayment/stripeRoute.js";
|
import stripeRoute from "./resources/StripePayment/stripeRoute.js";
|
||||||
|
|
||||||
|
import SeoRoute from "./resources/SEO&Analytics/SEORouter.js"
|
||||||
|
|
||||||
//short urls
|
//short urls
|
||||||
// import ShortUrlRouter from "./resources/Businesses/Short_Urls/ShortUrlRoute.js";
|
// import ShortUrlRouter from "./resources/Businesses/Short_Urls/ShortUrlRoute.js";
|
||||||
|
|
||||||
@ -203,6 +205,8 @@ app.use("/api/tax", TaxRouter);
|
|||||||
app.use("/api/config", ConfigRouter);
|
app.use("/api/config", ConfigRouter);
|
||||||
|
|
||||||
app.use("/api/stripe",stripeRoute);
|
app.use("/api/stripe",stripeRoute);
|
||||||
|
|
||||||
|
app.use("/api/seo",SeoRoute);
|
||||||
//config specialty
|
//config specialty
|
||||||
// app.use("/api/config/specialty", SpecialtiesRouter);
|
// app.use("/api/config/specialty", SpecialtiesRouter);
|
||||||
//specialties
|
//specialties
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
const { Schema, model } = mongoose;
|
const { Schema, model } = mongoose;
|
||||||
|
39
resources/SEO&Analytics/SEOController.js
Normal file
39
resources/SEO&Analytics/SEOController.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
33
resources/SEO&Analytics/SEOModel.js
Normal file
33
resources/SEO&Analytics/SEOModel.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
|
const { Schema, model } = mongoose;
|
||||||
|
|
||||||
|
const SeoRequestSchema = new mongoose.Schema(
|
||||||
|
{
|
||||||
|
|
||||||
|
GoogleTag: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [25, "tag cannot exceed 25 characters"],
|
||||||
|
required: [true, "Please Enter google tag "],
|
||||||
|
},
|
||||||
|
FacebookPixel: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [25, "tag cannot exceed 25 characters"],
|
||||||
|
required: [true, "Please Enter Facebook Pixel "],
|
||||||
|
},
|
||||||
|
GoogleAnalytics: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [500, "google analytics cannot exceed 500 characters"],
|
||||||
|
required: [true, "Please Enter google analytics"],
|
||||||
|
},
|
||||||
|
MicrosoftClarity: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [500, "Microsoft clarity cannot exceed 500 characters"],
|
||||||
|
required: [true, "Please Enter microsoft clarity"],
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
{ timestamps: true, versionKey: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SeoRequest = mongoose.model("SeoRequest", SeoRequestSchema);
|
12
resources/SEO&Analytics/SEORouter.js
Normal file
12
resources/SEO&Analytics/SEORouter.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import express from "express";
|
||||||
|
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
||||||
|
import { AddNewSeoRequest } from "./SEOController.js";
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router
|
||||||
|
.route("/new")
|
||||||
|
.post(isAuthenticatedUser, authorizeRoles("admin"), AddNewSeoRequest);
|
||||||
|
|
||||||
|
|
||||||
|
export default router;
|
Loading…
Reference in New Issue
Block a user