diff --git a/.env b/.env
index f10d8bb..e8a5d77 100644
--- a/.env
+++ b/.env
@@ -1,15 +1,15 @@
-mongodb
-DB_URL="mongodb+srv://printsignsAdmin:dtMmP8h0AjxYpDah@cluster0.srx6va5.mongodb.net/?retryWrites=true&w=majority"
-
+# mongodb
+# DB_URL="mongodb+srv://Get-Sygnal:Doo1KHDIWWlSsTFW@cluster0.zom9mlq.mongodb.net/?retryWrites=true&w=majority"
+DB_URL="mongodb+srv://Get-Sygnal:Doo1KHDIWWlSsTFW@cluster.zom9mlq.mongodb.net/test?ssl=true&sslValidate=true"
PORT = 8000
JWT_SECRET = jdvnvjwrniwj4562jn6@1xsbfeh@wre4Njdf;
-// Bolo cloudinary credential
-CLOUDINARY_NAME = "dhkmsthix"
-CLOUDINARY_API_KEY = "938923891277448"
-CLOUDINARY_API_SECRET = "KkjTq-3v_vZpWqiOEnnWmGf7DoM"
+# // Get-Sygnal cloudinary credential
+CLOUDINARY_NAME = "dne5rkqkt"
+CLOUDINARY_API_KEY = "335493365729323"
+CLOUDINARY_API_SECRET = "uBPv-qUGSGBwVyUKya6tGZjrBSc"
# SEND_EMAIL_FROM="project.boloai@gmail.com"
@@ -20,16 +20,16 @@ CLOUDINARY_API_SECRET = "KkjTq-3v_vZpWqiOEnnWmGf7DoM"
# SMPT_PORT="587"
# SMPT_MAIL="beameri.team@gmail.com"
# SMPT_PASSWORD="xsmtpsib-a88c224860249a3f1e0765e0e3d119c1bf07ad21f2859318fbf50975deee1711-JrdPpfsvF6LwEn4A"
-SEND_EMAIL_FROM="Sales@thesolarsign.com"
+SEND_EMAIL_FROM="admin@getsygnal.com"
# Bolo Ai
SENDGRID_API_KEY="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"
SMPT_HOST="smtp-relay.brevo.com"
SMPT_PORT="587"
-SMPT_MAIL="polytek01@yahoo.com"
-SMPT_PASSWORD="254GT9dQngVKIFHz"
-# SMPT_PASSWORD="CBNyJ4bZ3XR1IUDc"
+SMPT_MAIL=" admin@getsygnal.com"
+SMPT_PASSWORD="j15Jb8UzhmMx07pN"
+# SMPT_PASSWORD="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"
PAYPAL_CLIENT_ID="AemCjVuWswklp1sWUo4peCFg9eS4bofMsMR0RCrVRB2DifYR1IUSrWqtHpVmQlrVMKTI2cWZXLJAdYwn"
PAYPAL_CLIENT_SECRET="EAo0Y9ff3jpHHg1QAbftdebfh7cb_-vnebhQrP9KALbCVer908yx2tO2eHO39r7EJSfqc4D69Qgx8R31"
\ No newline at end of file
diff --git a/Utils/cloudinary.js b/Utils/cloudinary.js
index dc46c05..396d860 100644
--- a/Utils/cloudinary.js
+++ b/Utils/cloudinary.js
@@ -1,21 +1,18 @@
import cloudinary from "cloudinary";
import { CloudinaryStorage } from "multer-storage-cloudinary";
import multer from "multer";
-import path from "path"
+import path from "path";
cloudinary.v2.config({
- cloud_name: process.env.CLOUDINARY_NAME,
- api_key: process.env.CLOUDINARY_API_KEY,
- api_secret: process.env.CLOUDINARY_API_SECRET,
+ cloud_name: process.env.CLOUDINARY_NAME,
+ api_key: process.env.CLOUDINARY_API_KEY,
+ api_secret: process.env.CLOUDINARY_API_SECRET,
});
-
-
-
const storage = new CloudinaryStorage({
- cloudinary: cloudinary,
- params: {
- folder: "Atp",
- },
+ cloudinary: cloudinary,
+ params: {
+ folder: "GetSygnal",
+ },
});
// export const upload = multer({
@@ -30,18 +27,16 @@ const storage = new CloudinaryStorage({
// },
// });
-
-
export const upload = multer({
- storage: multer.diskStorage({}),
- fileFilter: (req, file, cb) => {
- let ext = path.extname(file.originalname);
- if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") {
- cb(new Error("File type not supported!"), false)
- return
- }
- cb(null, true);
+ storage: multer.diskStorage({}),
+ fileFilter: (req, file, cb) => {
+ let ext = path.extname(file.originalname);
+ if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") {
+ cb(new Error("File type not supported!"), false);
+ return;
}
+ cb(null, true);
+ },
});
-export default cloudinary;
\ No newline at end of file
+export default cloudinary;
diff --git a/Utils/reusableApi.js b/Utils/reusableApi.js
index 757b869..436030e 100644
--- a/Utils/reusableApi.js
+++ b/Utils/reusableApi.js
@@ -13,176 +13,176 @@
import cloudinary from "./cloudinary.js";
const getEntities = async (
- req,
- res,
- Entity,
- isUser = false,
- criteria = false,
- log = false
+ req,
+ res,
+ Entity,
+ isUser = false,
+ criteria = false,
+ log = false
) => {
- //pagination added filter can change so it needs to be dynamic will add it in future
- let { page, limit } = req.query;
- page = page * 1;
- limit = limit * 1;
- let limitVal = limit;
- let skipeValue = (page - 1) * limitVal;
- if (isUser) {
- if (!req.user) return res.status(400).json({ message: "User not found." });
- }
- try {
- if (criteria) {
- const entity = await Entity.find({ createdBy: req.user._id });
- return res.status(200).json({ status: "OK", data: entity });
- }
- const totalRecords = await Entity.countDocuments({});
- const entity = await Entity.find({})
- .sort({ createdAt: -1 })
- .limit(limitVal)
- .skip(skipeValue);
- res
- .status(200)
- .json({ status: "OK", totalRecords: totalRecords, data: entity });
- } catch (err) {
- log && console.log(err);
- return res.status(500).json({ message: "Unable to fetch." });
+ //pagination added filter can change so it needs to be dynamic will add it in future
+ let { page, limit } = req.query;
+ page = page * 1;
+ limit = limit * 1;
+ let limitVal = limit;
+ let skipeValue = (page - 1) * limitVal;
+ if (isUser) {
+ if (!req.user) return res.status(400).json({ message: "User not found." });
+ }
+ try {
+ if (criteria) {
+ const entity = await Entity.find({ createdBy: req.user._id });
+ return res.status(200).json({ status: "OK", data: entity });
}
+ const totalRecords = await Entity.countDocuments({});
+ const entity = await Entity.find({})
+ .sort({ createdAt: -1 })
+ .limit(limitVal)
+ .skip(skipeValue);
+ res
+ .status(200)
+ .json({ status: "OK", totalRecords: totalRecords, data: entity });
+ } catch (err) {
+ log && console.log(err);
+ return res.status(500).json({ message: "Unable to fetch." });
+ }
};
const getEntity = async (req, res, Entity, isUser = false, log = false) => {
- if (isUser) {
- 1;
- if (!req.user) return res.status(400).json({ message: "User not found." });
- }
- try {
- const entity = await Entity.findById(req.params.id);
- if (!entity) {
- return res.status(400).json({ message: "Not found" });
- }
- res.status(200).json({ status: "OK", data: entity });
- } catch (err) {
- log && console.log(err);
- return res.status(500).json({ message: "Unable to find" });
+ if (isUser) {
+ 1;
+ if (!req.user) return res.status(400).json({ message: "User not found." });
+ }
+ try {
+ const entity = await Entity.findById(req.params.id);
+ if (!entity) {
+ return res.status(400).json({ message: "Not found" });
}
+ res.status(200).json({ status: "OK", data: entity });
+ } catch (err) {
+ log && console.log(err);
+ return res.status(500).json({ message: "Unable to find" });
+ }
};
const addEntity = async (
- req,
- res,
- Entity,
- isUser = false,
- isSingleImage = false,
- isMultipleImages = false,
- isCreatedBy = false,
- log = false
+ req,
+ res,
+ Entity,
+ isUser = false,
+ isSingleImage = false,
+ isMultipleImages = false,
+ isCreatedBy = false,
+ log = false
) => {
- if (isUser) {
- if (!req.user) return res.status(400).json({ message: "User not found." });
+ if (isUser) {
+ if (!req.user) return res.status(400).json({ message: "User not found." });
+ }
+ try {
+ if (isCreatedBy) {
+ req.body.createdBy = req.user._id;
}
- try {
- if (isCreatedBy) {
- req.body.createdBy = req.user._id;
- }
- if (isSingleImage) {
- if (req.file) {
- const result = await cloudinary.v2.uploader.upload(req.file.path);
- const image = { url: result.secure_url, public_id: result.public_id };
- req.body.image = image;
- }
- }
- if (isMultipleImages) {
- const imageUrlList = [];
- for (var i = 0; i < req.files.length; i++) {
- const locaFilePath = req.files[i].path;
- const result = await cloudinary.v2.uploader.upload(locaFilePath);
- imageUrlList.push({ url: result.url, public_id: result.public_id });
- }
- req.body.files = imageUrlList;
- }
- const entity = await Entity.create(req.body);
- res.status(200).json({ status: "OK", data: entity });
- } catch (err) {
- log && console.log(err);
- return res.status(500).json({ message: "Unable to create." });
+ if (isSingleImage) {
+ if (req.file) {
+ const result = await cloudinary.v2.uploader.upload(req.file.path);
+ const image = { url: result.secure_url, public_id: result.public_id };
+ req.body.image = image;
+ }
}
+ if (isMultipleImages) {
+ const imageUrlList = [];
+ for (var i = 0; i < req.files.length; i++) {
+ const locaFilePath = req.files[i].path;
+ const result = await cloudinary.v2.uploader.upload(locaFilePath);
+ imageUrlList.push({ url: result.url, public_id: result.public_id });
+ }
+ req.body.files = imageUrlList;
+ }
+ const entity = await Entity.create(req.body);
+ res.status(200).json({ status: "OK", data: entity });
+ } catch (err) {
+ log && console.log(err);
+ return res.status(500).json({ message: "Unable to create." });
+ }
};
const updateEntity = async (
- req,
- res,
- Entity,
- isUser = false,
- isSingleImage = false,
- isMultipleImages = false,
- log = false
+ req,
+ res,
+ Entity,
+ isUser = false,
+ isSingleImage = false,
+ isMultipleImages = false,
+ log = false
) => {
- if (isUser) {
- if (!req.user) return res.status(400).json({ message: "User not found." });
+ if (isUser) {
+ if (!req.user) return res.status(400).json({ message: "User not found." });
+ }
+ let entity = await Entity.findById(req.params.id);
+ if (!entity) {
+ return res.status(400).json({ message: "Not found" });
+ }
+ try {
+ if (isSingleImage) {
+ await cloudinary.v2.uploader.destroy(req.body.public_id);
+ if (req.file) {
+ const result = await cloudinary.v2.uploader.upload(req.file.path);
+ const image = { url: result.url, public_id: result.public_id };
+ req.body.image = image;
+ }
}
- let entity = await Entity.findById(req.params.id);
- if (!entity) {
- return res.status(400).json({ message: "Not found" });
- }
- try {
- if (isSingleImage) {
- await cloudinary.v2.uploader.destroy(req.body.public_id);
- if (req.file) {
- const result = await cloudinary.v2.uploader.upload(req.file.path);
- const image = { url: result.url, public_id: result.public_id };
- req.body.image = image;
- }
- }
- if (isMultipleImages) {
- for (let i = 0; i < req.body.publicIdArray; i++) {
- await cloudinary.v2.uploader.destroy(req.body.publicIdArray[i]);
- }
- const imageUrlList = [];
- for (var i = 0; i < req.files.length; i++) {
- const locaFilePath = req.files[i].path;
- const result = await cloudinary.v2.uploader.upload(locaFilePath);
- imageUrlList.push({ url: result.url, public_id: result.public_id });
- }
- req.body.files = imageUrlList;
- }
- entity = await Entity.findByIdAndUpdate(req.params.id, req.body, {
- new: true,
- });
- res.status(200).json({ status: "OK", data: entity });
- } catch (err) {
- log && console.log(err);
- return res.status(500).json({ message: "Unable to update." });
+ if (isMultipleImages) {
+ for (let i = 0; i < req.body.publicIdArray; i++) {
+ await cloudinary.v2.uploader.destroy(req.body.publicIdArray[i]);
+ }
+ const imageUrlList = [];
+ for (var i = 0; i < req.files.length; i++) {
+ const locaFilePath = req.files[i].path;
+ const result = await cloudinary.v2.uploader.upload(locaFilePath);
+ imageUrlList.push({ url: result.url, public_id: result.public_id });
+ }
+ req.body.files = imageUrlList;
}
+ entity = await Entity.findByIdAndUpdate(req.params.id, req.body, {
+ new: true,
+ });
+ res.status(200).json({ status: "OK", data: entity });
+ } catch (err) {
+ log && console.log(err);
+ return res.status(500).json({ message: "Unable to update." });
+ }
};
const deleteEntity = async (
- req,
- res,
- Entity,
- isUser = false,
- isSingleImage = false,
- isMultipleImages = false,
- log = false
+ req,
+ res,
+ Entity,
+ isUser = false,
+ isSingleImage = false,
+ isMultipleImages = false,
+ log = false
) => {
- if (isUser) {
- if (!req.user) return res.status(400).json({ message: "User not found." });
- }
- // if (isSingleImage) {
- // req.body.imageUrl = req.file.location;
+ if (isUser) {
+ if (!req.user) return res.status(400).json({ message: "User not found." });
+ }
+ // if (isSingleImage) {
+ // req.body.imageUrl = req.file.location;
+ // }
+ try {
+ // if (isSingleImage) {
+ // await cloudinary.v2.uploader.destroy(entity.image.public_id);
+ // }
+ // if (isMultipleImages) {
+ // for (let i = 0; i < entity.files.length; i++) {
+ // await cloudinary.v2.uploader.destroy(entity.files[i].public_id);
// }
- try {
- // if (isSingleImage) {
- // await cloudinary.v2.uploader.destroy(entity.image.public_id);
- // }
- // if (isMultipleImages) {
- // for (let i = 0; i < entity.files.length; i++) {
- // await cloudinary.v2.uploader.destroy(entity.files[i].public_id);
- // }
- // }
- await Entity.deleteOne({ _id: req.params.id });
- res.status(200).json({ status: "OK", message: "Deleted Successfully" });
- } catch (err) {
- log && console.log(err);
- return res.status(500).json({ message: "Unable to delete" });
- }
+ // }
+ await Entity.deleteOne({ _id: req.params.id });
+ res.status(200).json({ status: "OK", message: "Deleted Successfully" });
+ } catch (err) {
+ log && console.log(err);
+ return res.status(500).json({ message: "Unable to delete" });
+ }
};
export { getEntities, getEntity, addEntity, updateEntity, deleteEntity };
diff --git a/app.js b/app.js
index 1c6db9e..3ce08dc 100644
--- a/app.js
+++ b/app.js
@@ -53,9 +53,9 @@ import PurposeRoute from "./resources/setting/Purpose/Purpose_routes.js";
// category Route
import categoryRoute from "./resources/Category/categoryRoutes.js";
import bannerRoute from "./resources/Banner/BannerRouter.js";
-import RegistrationImageRoute from './resources/RegistrationImage/RegistrationImageRoute.js';
-import loginImageRoute from './resources/LoginImage/LoginImageRoute.js'
-import shopImageRoute from './resources/ShopPageImage/ShopPageImageRoute.js'
+import RegistrationImageRoute from "./resources/RegistrationImage/RegistrationImageRoute.js";
+import loginImageRoute from "./resources/LoginImage/LoginImageRoute.js";
+import shopImageRoute from "./resources/ShopPageImage/ShopPageImageRoute.js";
import ContentRoute from "./resources/Content/ContentRoutes.js";
import UserAddressRoute from "./resources/userAddress/useAddressRoute.js";
//business_Type
@@ -83,9 +83,9 @@ app.use("/api", ProductRouter);
app.use("/api/category", categoryRoute);
app.use("/api/banner", bannerRoute);
// registration image
-app.use('/api/registerImage', RegistrationImageRoute)
-app.use('/api/loginImage', loginImageRoute)
-app.use('/api/shopImage', shopImageRoute)
+app.use("/api/registerImage", RegistrationImageRoute);
+app.use("/api/loginImage", loginImageRoute);
+app.use("/api/shopImage", shopImageRoute);
// Content
app.use("/api/content", ContentRoute);
// User Address
diff --git a/resources/Banner/BannerController.js b/resources/Banner/BannerController.js
index 14a7c4d..c2084d1 100644
--- a/resources/Banner/BannerController.js
+++ b/resources/Banner/BannerController.js
@@ -17,7 +17,7 @@ export const addBanner = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath,
{
- folder: "jatinMor/banner",
+ folder: "GetSygnal/banner",
}
);
@@ -84,7 +84,7 @@ export const updateBanner = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath,
{
- folder: "jatinMor/banner",
+ folder: "GetSygnal/banner",
}
);
const update = await BannerModel.findOneAndUpdate(
diff --git a/resources/Category/categoryController.js b/resources/Category/categoryController.js
index 3308bac..0bc68e6 100644
--- a/resources/Category/categoryController.js
+++ b/resources/Category/categoryController.js
@@ -16,7 +16,7 @@ export const addCategory = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
categoryImage.tempFilePath,
{
- folder: "jatinMor/category",
+ folder: "GetSygnal/category",
}
);
@@ -83,7 +83,7 @@ export const updateCategory = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
categoryImag.tempFilePath,
{
- folder: "jatinMor/category",
+ folder: "GetSygnal/category",
}
);
const update = await CategoryModel.findOneAndUpdate(
diff --git a/resources/Design/designController.js b/resources/Design/designController.js
index 1b7b22f..d2208a3 100644
--- a/resources/Design/designController.js
+++ b/resources/Design/designController.js
@@ -41,7 +41,7 @@ const imageUpload = multer({ storage: imageStorage }).any();
// const result = await cloudinary.v2.uploader.upload(
// designImage.tempFilePath,
// {
-// folder: "jatinMor/design",
+// folder: "GetSygnal/design",
// }
// );
@@ -170,7 +170,7 @@ export const updateDesign = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
designImage.tempFilePath,
{
- folder: "jatinMor/design",
+ folder: "GetSygnal/design",
}
);
const update = await DesignModel.findOneAndUpdate(
diff --git a/resources/LoginImage/LoginImageController.js b/resources/LoginImage/LoginImageController.js
index 49dfa65..60169ef 100644
--- a/resources/LoginImage/LoginImageController.js
+++ b/resources/LoginImage/LoginImageController.js
@@ -18,7 +18,7 @@ export const addImage = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath,
{
- folder: "jatinMor/loginImage",
+ folder: "GetSygnal/loginImage",
}
);
@@ -84,7 +84,7 @@ export const getImage = async (req, res) => {
// const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath,
// {
-// folder: "jatinMor/loginImage",
+// folder: "GetSygnal/loginImage",
// }
// );
@@ -153,7 +153,7 @@ export const updateImage = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath,
{
- folder: "jatinMor/loginImage",
+ folder: "GetSygnal/loginImage",
}
);
console.log("result", result);
diff --git a/resources/Products/ProductController.js b/resources/Products/ProductController.js
index cd2c78a..8f5f735 100644
--- a/resources/Products/ProductController.js
+++ b/resources/Products/ProductController.js
@@ -24,7 +24,7 @@ export const createProduct = async (req, res) => {
const imagesLinks = [];
for (let i = 0; i < images.length; i++) {
const result = await cloudinary.v2.uploader.upload(images[i], {
- folder: "jatinMor/product",
+ folder: "GetSygnal/product",
});
imagesLinks.push({
@@ -112,7 +112,7 @@ export const updateProduct = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
newuploadImages[i].tempFilePath,
{
- folder: "jatinMor/product",
+ folder: "GetSygnal/product",
}
);
diff --git a/resources/RegistrationImage/RegistrationImageController.js b/resources/RegistrationImage/RegistrationImageController.js
index 7a52e4b..487133e 100644
--- a/resources/RegistrationImage/RegistrationImageController.js
+++ b/resources/RegistrationImage/RegistrationImageController.js
@@ -5,60 +5,60 @@ import { RegistrationImageModel } from "./RegistrationImageModel.js";
// Add new Category
export const addImage = async (req, res) => {
- // const { bannerName } = req.body;
- const { bannerImage } = req.files;
- // console.log("image", bannerImage);
- // console.log(categoryName, categoryImage);
+ // const { bannerName } = req.body;
+ const { bannerImage } = req.files;
+ // console.log("image", bannerImage);
+ // console.log(categoryName, categoryImage);
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- try {
- if (!mongoose.Types.ObjectId.isValid(req.user._id)) {
- return res.status(400).json({ message: "please login again " });
- }
- const result = await cloudinary.v2.uploader.upload(
- bannerImage.tempFilePath,
- {
- folder: "jatinMor/registrationImage",
- }
- );
-
- if (result) {
- const regsiterImage = await RegistrationImageModel.create({
- image: result,
- addedBy: req.user._id,
- });
- if (regsiterImage) {
- return res
- .status(201)
- .json({ success: true, regsiterImage, message: "Image Added" });
- }
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went Wrong",
- });
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ try {
+ if (!mongoose.Types.ObjectId.isValid(req.user._id)) {
+ return res.status(400).json({ message: "please login again " });
}
+ const result = await cloudinary.v2.uploader.upload(
+ bannerImage.tempFilePath,
+ {
+ folder: "GetSygnal/registrationImage",
+ }
+ );
+
+ if (result) {
+ const regsiterImage = await RegistrationImageModel.create({
+ image: result,
+ addedBy: req.user._id,
+ });
+ if (regsiterImage) {
+ return res
+ .status(201)
+ .json({ success: true, regsiterImage, message: "Image Added" });
+ }
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
};
export const getImage = async (req, res) => {
- try {
- // if (!req?.user) return res.status(400).json({ message: "please login !" });
- const image = await RegistrationImageModel.find().sort({
- createdAt: -1,
- });
+ try {
+ // if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const image = await RegistrationImageModel.find().sort({
+ createdAt: -1,
+ });
- if (!image) {
- return res.status(404).json({ message: "No categories found" });
- }
- // console.log("image", image);
- res.status(200).json({ success: true, image });
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ if (!image) {
+ return res.status(404).json({ message: "No categories found" });
}
+ // console.log("image", image);
+ res.status(200).json({ success: true, image });
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
// export const updateImage = async (req, res) => {
// try {
@@ -84,7 +84,7 @@ export const getImage = async (req, res) => {
// const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath,
// {
-// folder: "jatinMor/registrationImage",
+// folder: "GetSygnal/registrationImage",
// }
// );
@@ -124,98 +124,101 @@ export const getImage = async (req, res) => {
// };
export const updateImage = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- const { _id } = req.params;
- const { bannerName } = req.body;
- const olderImage = req.body?.olderImage;
- const bannerImag = req.files?.bannerImage;
- // console.log("bannerImag", bannerImag);
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const { _id } = req.params;
+ const { bannerName } = req.body;
+ const olderImage = req.body?.olderImage;
+ const bannerImag = req.files?.bannerImage;
+ // console.log("bannerImag", bannerImag);
- if (!mongoose.Types.ObjectId.isValid(_id)) {
- return res.status(404).json({ error: "Can not find the document " });
- }
- // console.log(JSON.parse(olderImage).length);
- // find the document with the id to delete the image from cloudinary
-
- if (olderImage) {
-
- const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id });
-
- // console.log("deletefromCloudinary", deletefromCloudinary)
- const deleteresponse = await cloudinary.v2.uploader.destroy(
- deletefromCloudinary.image.public_id
- );
-
-
- if (deleteresponse) {
-
- const result = await cloudinary.v2.uploader.upload(
- bannerImag.tempFilePath,
- {
- folder: "jatinMor/registrationImage",
- }
- );
- console.log("result", result);
- const update = await RegistrationImageModel.findOneAndUpdate(
- { _id: _id },
- { image: result }, // Provide the updated categoryName
- { new: true } // To return the updated document
- );
- if (!update) {
- return res
- .status(404)
- .json({ message: "Can not update document, something went wrong" });
- } else {
- return res.status(200).json({ success: true, update });
- }
- }
- } else {
- const update = await RegistrationImageModel.findOneAndUpdate(
- { _id: _id },
- { image: JSON.parse(olderImage) }, // Provide the updated categoryName
- { new: true } // To return the updated document
- );
- if (update) {
- return res.status(200).json({ success: true, update });
- }
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ if (!mongoose.Types.ObjectId.isValid(_id)) {
+ return res.status(404).json({ error: "Can not find the document " });
}
+ // console.log(JSON.parse(olderImage).length);
+ // find the document with the id to delete the image from cloudinary
+
+ if (olderImage) {
+ const deletefromCloudinary = await RegistrationImageModel.findOne({
+ _id: _id,
+ });
+
+ // console.log("deletefromCloudinary", deletefromCloudinary)
+ const deleteresponse = await cloudinary.v2.uploader.destroy(
+ deletefromCloudinary.image.public_id
+ );
+
+ if (deleteresponse) {
+ const result = await cloudinary.v2.uploader.upload(
+ bannerImag.tempFilePath,
+ {
+ folder: "GetSygnal/registrationImage",
+ }
+ );
+ console.log("result", result);
+ const update = await RegistrationImageModel.findOneAndUpdate(
+ { _id: _id },
+ { image: result }, // Provide the updated categoryName
+ { new: true } // To return the updated document
+ );
+ if (!update) {
+ return res
+ .status(404)
+ .json({ message: "Can not update document, something went wrong" });
+ } else {
+ return res.status(200).json({ success: true, update });
+ }
+ }
+ } else {
+ const update = await RegistrationImageModel.findOneAndUpdate(
+ { _id: _id },
+ { image: JSON.parse(olderImage) }, // Provide the updated categoryName
+ { new: true } // To return the updated document
+ );
+ if (update) {
+ return res.status(200).json({ success: true, update });
+ }
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
export const deleteImage = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- const { _id } = req.params;
- if (!mongoose.Types.ObjectId.isValid(_id)) {
- return res.status(404).json({ error: "Can not find the document " });
- }
-
- const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id });
- // console.log(deletefromCloudinary);
- const deleteresponse = await cloudinary.v2.uploader.destroy(
- deletefromCloudinary.image.public_id
- );
- if (deleteresponse) {
- const deleteBanner = await RegistrationImageModel.findOneAndDelete({ _id: _id });
- if (!deleteBanner) {
- return res.status(404).json({
- error: "Can not find the document with the provided id to delete ",
- });
- }
- res.status(200).json({ success: true, deleteBanner });
- } else {
- return res.status(404).json({ error: "can not delete the banner " });
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const { _id } = req.params;
+ if (!mongoose.Types.ObjectId.isValid(_id)) {
+ return res.status(404).json({ error: "Can not find the document " });
}
+
+ const deletefromCloudinary = await RegistrationImageModel.findOne({
+ _id: _id,
+ });
+ // console.log(deletefromCloudinary);
+ const deleteresponse = await cloudinary.v2.uploader.destroy(
+ deletefromCloudinary.image.public_id
+ );
+ if (deleteresponse) {
+ const deleteBanner = await RegistrationImageModel.findOneAndDelete({
+ _id: _id,
+ });
+ if (!deleteBanner) {
+ return res.status(404).json({
+ error: "Can not find the document with the provided id to delete ",
+ });
+ }
+ res.status(200).json({ success: true, deleteBanner });
+ } else {
+ return res.status(404).json({ error: "can not delete the banner " });
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
diff --git a/resources/ShopPageImage/ShopPageImageController.js b/resources/ShopPageImage/ShopPageImageController.js
index 6fdb04f..71e9560 100644
--- a/resources/ShopPageImage/ShopPageImageController.js
+++ b/resources/ShopPageImage/ShopPageImageController.js
@@ -3,64 +3,62 @@ import mongoose from "mongoose";
import cloudinary from "../../Utils/cloudinary.js";
import { ShopPageImageModel } from "./ShopPageImageModel.js";
-
-
-// Add new Category
+// Add new Category
export const addImage = async (req, res) => {
- // const { bannerName } = req.body;
- const { bannerImage } = req.files;
- // console.log("image", bannerImage);
- // console.log(categoryName, categoryImage);
+ // const { bannerName } = req.body;
+ const { bannerImage } = req.files;
+ // console.log("image", bannerImage);
+ // console.log(categoryName, categoryImage);
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- try {
- if (!mongoose.Types.ObjectId.isValid(req.user._id)) {
- return res.status(400).json({ message: "please login again " });
- }
- const result = await cloudinary.v2.uploader.upload(
- bannerImage.tempFilePath,
- {
- folder: "jatinMor/shopImage",
- }
- );
-
- if (result) {
- const regsiterImage = await ShopPageImageModel.create({
- image: result,
- addedBy: req.user._id,
- });
- if (regsiterImage) {
- return res
- .status(201)
- .json({ success: true, regsiterImage, message: "Image Added" });
- }
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went Wrong",
- });
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ try {
+ if (!mongoose.Types.ObjectId.isValid(req.user._id)) {
+ return res.status(400).json({ message: "please login again " });
}
+ const result = await cloudinary.v2.uploader.upload(
+ bannerImage.tempFilePath,
+ {
+ folder: "GetSygnal/shopImage",
+ }
+ );
+
+ if (result) {
+ const regsiterImage = await ShopPageImageModel.create({
+ image: result,
+ addedBy: req.user._id,
+ });
+ if (regsiterImage) {
+ return res
+ .status(201)
+ .json({ success: true, regsiterImage, message: "Image Added" });
+ }
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
};
export const getImage = async (req, res) => {
- try {
- // if (!req?.user) return res.status(400).json({ message: "please login !" });
- const image = await ShopPageImageModel.find().sort({
- createdAt: -1,
- });
+ try {
+ // if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const image = await ShopPageImageModel.find().sort({
+ createdAt: -1,
+ });
- if (!image) {
- return res.status(404).json({ message: "No categories found" });
- }
- // console.log("image", image);
- res.status(200).json({ success: true, image });
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ if (!image) {
+ return res.status(404).json({ message: "No categories found" });
}
+ // console.log("image", image);
+ res.status(200).json({ success: true, image });
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
// export const updateImage = async (req, res) => {
// try {
@@ -86,7 +84,7 @@ export const getImage = async (req, res) => {
// const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath,
// {
-// folder: "jatinMor/shopImage",
+// folder: "GetSygnal/shopImage",
// }
// );
@@ -126,98 +124,99 @@ export const getImage = async (req, res) => {
// };
export const updateImage = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- const { _id } = req.params;
- const { bannerName } = req.body;
- const olderImage = req.body?.olderImage;
- const bannerImag = req.files?.bannerImage;
- // console.log("bannerImag", bannerImag);
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const { _id } = req.params;
+ const { bannerName } = req.body;
+ const olderImage = req.body?.olderImage;
+ const bannerImag = req.files?.bannerImage;
+ // console.log("bannerImag", bannerImag);
- if (!mongoose.Types.ObjectId.isValid(_id)) {
- return res.status(404).json({ error: "Can not find the document " });
- }
- // console.log(JSON.parse(olderImage).length);
- // find the document with the id to delete the image from cloudinary
-
- if (olderImage) {
-
- const deletefromCloudinary = await ShopPageImageModel.findOne({ _id: _id });
-
- // console.log("deletefromCloudinary", deletefromCloudinary)
- const deleteresponse = await cloudinary.v2.uploader.destroy(
- deletefromCloudinary.image.public_id
- );
-
-
- if (deleteresponse) {
-
- const result = await cloudinary.v2.uploader.upload(
- bannerImag.tempFilePath,
- {
- folder: "jatinMor/shopImage",
- }
- );
- console.log("result", result);
- const update = await ShopPageImageModel.findOneAndUpdate(
- { _id: _id },
- { image: result }, // Provide the updated categoryName
- { new: true } // To return the updated document
- );
- if (!update) {
- return res
- .status(404)
- .json({ message: "Can not update document, something went wrong" });
- } else {
- return res.status(200).json({ success: true, update });
- }
- }
- } else {
- const update = await ShopPageImageModel.findOneAndUpdate(
- { _id: _id },
- { image: JSON.parse(olderImage) }, // Provide the updated categoryName
- { new: true } // To return the updated document
- );
- if (update) {
- return res.status(200).json({ success: true, update });
- }
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ if (!mongoose.Types.ObjectId.isValid(_id)) {
+ return res.status(404).json({ error: "Can not find the document " });
}
+ // console.log(JSON.parse(olderImage).length);
+ // find the document with the id to delete the image from cloudinary
+
+ if (olderImage) {
+ const deletefromCloudinary = await ShopPageImageModel.findOne({
+ _id: _id,
+ });
+
+ // console.log("deletefromCloudinary", deletefromCloudinary)
+ const deleteresponse = await cloudinary.v2.uploader.destroy(
+ deletefromCloudinary.image.public_id
+ );
+
+ if (deleteresponse) {
+ const result = await cloudinary.v2.uploader.upload(
+ bannerImag.tempFilePath,
+ {
+ folder: "GetSygnal/shopImage",
+ }
+ );
+ console.log("result", result);
+ const update = await ShopPageImageModel.findOneAndUpdate(
+ { _id: _id },
+ { image: result }, // Provide the updated categoryName
+ { new: true } // To return the updated document
+ );
+ if (!update) {
+ return res
+ .status(404)
+ .json({ message: "Can not update document, something went wrong" });
+ } else {
+ return res.status(200).json({ success: true, update });
+ }
+ }
+ } else {
+ const update = await ShopPageImageModel.findOneAndUpdate(
+ { _id: _id },
+ { image: JSON.parse(olderImage) }, // Provide the updated categoryName
+ { new: true } // To return the updated document
+ );
+ if (update) {
+ return res.status(200).json({ success: true, update });
+ }
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
export const deleteImage = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- const { _id } = req.params;
- if (!mongoose.Types.ObjectId.isValid(_id)) {
- return res.status(404).json({ error: "Can not find the document " });
- }
-
- const deletefromCloudinary = await ShopPageImageModel.findOne({ _id: _id });
- // console.log(deletefromCloudinary);
- const deleteresponse = await cloudinary.v2.uploader.destroy(
- deletefromCloudinary.image.public_id
- );
- if (deleteresponse) {
- const deleteBanner = await ShopPageImageModel.findOneAndDelete({ _id: _id });
- if (!deleteBanner) {
- return res.status(404).json({
- error: "Can not find the document with the provided id to delete ",
- });
- }
- res.status(200).json({ success: true, deleteBanner });
- } else {
- return res.status(404).json({ error: "can not delete the banner " });
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : "Something went wrong",
- });
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ const { _id } = req.params;
+ if (!mongoose.Types.ObjectId.isValid(_id)) {
+ return res.status(404).json({ error: "Can not find the document " });
}
+
+ const deletefromCloudinary = await ShopPageImageModel.findOne({ _id: _id });
+ // console.log(deletefromCloudinary);
+ const deleteresponse = await cloudinary.v2.uploader.destroy(
+ deletefromCloudinary.image.public_id
+ );
+ if (deleteresponse) {
+ const deleteBanner = await ShopPageImageModel.findOneAndDelete({
+ _id: _id,
+ });
+ if (!deleteBanner) {
+ return res.status(404).json({
+ error: "Can not find the document with the provided id to delete ",
+ });
+ }
+ res.status(200).json({ success: true, deleteBanner });
+ } else {
+ return res.status(404).json({ error: "can not delete the banner " });
+ }
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went wrong",
+ });
+ }
};
diff --git a/resources/Testimonials/TestimonialController.js b/resources/Testimonials/TestimonialController.js
index bcd532f..98798d8 100644
--- a/resources/Testimonials/TestimonialController.js
+++ b/resources/Testimonials/TestimonialController.js
@@ -1,91 +1,84 @@
-
import cloudinary from "../../Utils/cloudinary.js";
-import { Testimonial } from "./TestimonialModel.js"
+import { Testimonial } from "./TestimonialModel.js";
export const AddNewTestimonial = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- // console.log(req?.user)
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ // console.log(req?.user)
- if (req.files) {
- let getImg = req.files.image
- const result = await cloudinary.v2.uploader.upload(getImg?.tempFilePath, {
- folder: "jatinMor/Testimonial",
- })
+ if (req.files) {
+ let getImg = req.files.image;
+ const result = await cloudinary.v2.uploader.upload(getImg?.tempFilePath, {
+ folder: "GetSygnal/Testimonial",
+ });
- let simage = {
- public_id: result.public_id,
- url: result.secure_url,
- }
- req.body.image = simage
-
- }
-
- req.body.user = req.user._id
- const testimonial = await Testimonial.create(req.body);
-
- res.status(201).json({
- success: true,
- testimonial,
- message: 'Testimonial Added',
- });
-
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : 'Something went Wrong',
- });
+ let simage = {
+ public_id: result.public_id,
+ url: result.secure_url,
+ };
+ req.body.image = simage;
}
-}
+
+ req.body.user = req.user._id;
+ const testimonial = await Testimonial.create(req.body);
+
+ res.status(201).json({
+ success: true,
+ testimonial,
+ message: "Testimonial Added",
+ });
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
+};
export const FindAllTestimonial = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- // console.log(req?.user)
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ // console.log(req?.user)
+ const testimonial = await Testimonial.find().sort({ createdAt: -1 });
+ if (testimonial) {
+ return res.status(200).json({
+ success: true,
+ testimonial,
+ message: "Fetched All Testimonial",
+ });
+ } else {
+ return res.status(404).json({
+ success: true,
- const testimonial = await Testimonial.find().sort({ createdAt: -1 });
- if (testimonial) {
- return res.status(200).json({
- success: true,
- testimonial,
- message: 'Fetched All Testimonial',
- });
- }
- else {
- return res.status(404).json({
- success: true,
-
- message: 'No Testimonial till Now',
- });
- }
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : 'Something went Wrong',
- });
+ message: "No Testimonial till Now",
+ });
}
-}
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
+};
export const FindOneTestimonial = async (req, res) => {
- try {
- if (!req?.user) return res.status(400).json({ message: "please login !" });
- // console.log(req?.user)
- if (!req.params.id) return res.status(400).json({ message: "please give ID !" });
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ // console.log(req?.user)
+ if (!req.params.id)
+ return res.status(400).json({ message: "please give ID !" });
-
- const testimonial = await Testimonial.findById(req.params.id);
- if (testimonial) {
- return res.status(200).json({
- success: true,
- testimonial,
- message: 'Fetched Testimonial',
- });
- }
-
- } catch (error) {
- res.status(500).json({
- success: false,
- message: error.message ? error.message : 'Something went Wrong',
- });
+ const testimonial = await Testimonial.findById(req.params.id);
+ if (testimonial) {
+ return res.status(200).json({
+ success: true,
+ testimonial,
+ message: "Fetched Testimonial",
+ });
}
-}
-
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
+};
diff --git a/resources/user/userController.js b/resources/user/userController.js
index 321a7d9..e815138 100644
--- a/resources/user/userController.js
+++ b/resources/user/userController.js
@@ -121,7 +121,7 @@ export const forgotPassword = async (req, res, next) => {
from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender
- subject: `The-solar-sign Password Recovery`,
+ subject: `Get Sygnal Password Recovery`,
html: `your new password is:
${passwords}
If you have not requested this email then, please ignore it.`,
});
diff --git a/server.js b/server.js
index 8c47f18..73a6b66 100644
--- a/server.js
+++ b/server.js
@@ -1,19 +1,18 @@
-
-import dotenv from 'dotenv'
-dotenv.config()
-import app from "./app.js"
-import connectDatabase from "./database/db.js"
-import cloudinary from "cloudinary"
+import dotenv from "dotenv";
+dotenv.config();
+import app from "./app.js";
+import connectDatabase from "./database/db.js";
+import cloudinary from "cloudinary";
// Connecting to database
-connectDatabase()
+connectDatabase();
//console.log(process.env.CLOUDINARY_API_KEY)
//cloudenary uses
cloudinary.config({
- cloud_name: process.env.CLOUDINARY_NAME,
- api_key: process.env.CLOUDINARY_API_KEY,
- api_secret: process.env.CLOUDINARY_API_SECRET,
+ cloud_name: process.env.CLOUDINARY_NAME,
+ api_key: process.env.CLOUDINARY_API_KEY,
+ api_secret: process.env.CLOUDINARY_API_SECRET,
});
//<---------deployement------------->``
// const data_dir = path.resolve();
@@ -26,14 +25,13 @@ cloudinary.config({
// );
// } else {
app.get("/", (req, res) => {
- res.send("API is running..");
+ res.send("API is running..");
});
// }
//<---------deployement------------->
const server = app.listen(process.env.PORT, () => {
- console.log(`Server is working on http://localhost:${process.env.PORT}`)
-})
-
+ console.log(`Server is working on http://localhost:${process.env.PORT}`);
+});
// Unhandled Promise Rejection
// process.on("unhandledRejection", (err) => {
@@ -43,4 +41,4 @@ const server = app.listen(process.env.PORT, () => {
// server.close(() => {
// process.exit(1);
// });
-// });
\ No newline at end of file
+// });