This commit is contained in:
pawan-dot 2024-01-16 12:56:23 +05:30
parent 1d885ea074
commit c999f1bf81
14 changed files with 554 additions and 566 deletions

22
.env
View File

@ -1,15 +1,15 @@
mongodb # mongodb
DB_URL="mongodb+srv://printsignsAdmin:dtMmP8h0AjxYpDah@cluster0.srx6va5.mongodb.net/?retryWrites=true&w=majority" # 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 PORT = 8000
JWT_SECRET = jdvnvjwrniwj4562jn6@1xsbfeh@wre4Njdf; JWT_SECRET = jdvnvjwrniwj4562jn6@1xsbfeh@wre4Njdf;
// Bolo cloudinary credential # // Get-Sygnal cloudinary credential
CLOUDINARY_NAME = "dhkmsthix" CLOUDINARY_NAME = "dne5rkqkt"
CLOUDINARY_API_KEY = "938923891277448" CLOUDINARY_API_KEY = "335493365729323"
CLOUDINARY_API_SECRET = "KkjTq-3v_vZpWqiOEnnWmGf7DoM" CLOUDINARY_API_SECRET = "uBPv-qUGSGBwVyUKya6tGZjrBSc"
# SEND_EMAIL_FROM="project.boloai@gmail.com" # SEND_EMAIL_FROM="project.boloai@gmail.com"
@ -20,16 +20,16 @@ CLOUDINARY_API_SECRET = "KkjTq-3v_vZpWqiOEnnWmGf7DoM"
# SMPT_PORT="587" # SMPT_PORT="587"
# SMPT_MAIL="beameri.team@gmail.com" # SMPT_MAIL="beameri.team@gmail.com"
# SMPT_PASSWORD="xsmtpsib-a88c224860249a3f1e0765e0e3d119c1bf07ad21f2859318fbf50975deee1711-JrdPpfsvF6LwEn4A" # SMPT_PASSWORD="xsmtpsib-a88c224860249a3f1e0765e0e3d119c1bf07ad21f2859318fbf50975deee1711-JrdPpfsvF6LwEn4A"
SEND_EMAIL_FROM="Sales@thesolarsign.com" SEND_EMAIL_FROM="admin@getsygnal.com"
# Bolo Ai # Bolo Ai
SENDGRID_API_KEY="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" SENDGRID_API_KEY="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"
SMPT_HOST="smtp-relay.brevo.com" SMPT_HOST="smtp-relay.brevo.com"
SMPT_PORT="587" SMPT_PORT="587"
SMPT_MAIL="polytek01@yahoo.com" SMPT_MAIL=" admin@getsygnal.com"
SMPT_PASSWORD="254GT9dQngVKIFHz" SMPT_PASSWORD="j15Jb8UzhmMx07pN"
# SMPT_PASSWORD="CBNyJ4bZ3XR1IUDc" # SMPT_PASSWORD="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"
PAYPAL_CLIENT_ID="AemCjVuWswklp1sWUo4peCFg9eS4bofMsMR0RCrVRB2DifYR1IUSrWqtHpVmQlrVMKTI2cWZXLJAdYwn" PAYPAL_CLIENT_ID="AemCjVuWswklp1sWUo4peCFg9eS4bofMsMR0RCrVRB2DifYR1IUSrWqtHpVmQlrVMKTI2cWZXLJAdYwn"
PAYPAL_CLIENT_SECRET="EAo0Y9ff3jpHHg1QAbftdebfh7cb_-vnebhQrP9KALbCVer908yx2tO2eHO39r7EJSfqc4D69Qgx8R31" PAYPAL_CLIENT_SECRET="EAo0Y9ff3jpHHg1QAbftdebfh7cb_-vnebhQrP9KALbCVer908yx2tO2eHO39r7EJSfqc4D69Qgx8R31"

View File

@ -1,20 +1,17 @@
import cloudinary from "cloudinary"; import cloudinary from "cloudinary";
import { CloudinaryStorage } from "multer-storage-cloudinary"; import { CloudinaryStorage } from "multer-storage-cloudinary";
import multer from "multer"; import multer from "multer";
import path from "path" import path from "path";
cloudinary.v2.config({ cloudinary.v2.config({
cloud_name: process.env.CLOUDINARY_NAME, cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_API_KEY, api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET, api_secret: process.env.CLOUDINARY_API_SECRET,
}); });
const storage = new CloudinaryStorage({ const storage = new CloudinaryStorage({
cloudinary: cloudinary, cloudinary: cloudinary,
params: { params: {
folder: "Atp", folder: "GetSygnal",
}, },
}); });
@ -30,18 +27,16 @@ const storage = new CloudinaryStorage({
// }, // },
// }); // });
export const upload = multer({ export const upload = multer({
storage: multer.diskStorage({}), storage: multer.diskStorage({}),
fileFilter: (req, file, cb) => { fileFilter: (req, file, cb) => {
let ext = path.extname(file.originalname); let ext = path.extname(file.originalname);
if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") { if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") {
cb(new Error("File type not supported!"), false) cb(new Error("File type not supported!"), false);
return return;
} }
cb(null, true); cb(null, true);
} },
}); });
export default cloudinary; export default cloudinary;

12
app.js
View File

@ -53,9 +53,9 @@ import PurposeRoute from "./resources/setting/Purpose/Purpose_routes.js";
// category Route // category Route
import categoryRoute from "./resources/Category/categoryRoutes.js"; import categoryRoute from "./resources/Category/categoryRoutes.js";
import bannerRoute from "./resources/Banner/BannerRouter.js"; import bannerRoute from "./resources/Banner/BannerRouter.js";
import RegistrationImageRoute from './resources/RegistrationImage/RegistrationImageRoute.js'; import RegistrationImageRoute from "./resources/RegistrationImage/RegistrationImageRoute.js";
import loginImageRoute from './resources/LoginImage/LoginImageRoute.js' import loginImageRoute from "./resources/LoginImage/LoginImageRoute.js";
import shopImageRoute from './resources/ShopPageImage/ShopPageImageRoute.js' import shopImageRoute from "./resources/ShopPageImage/ShopPageImageRoute.js";
import ContentRoute from "./resources/Content/ContentRoutes.js"; import ContentRoute from "./resources/Content/ContentRoutes.js";
import UserAddressRoute from "./resources/userAddress/useAddressRoute.js"; import UserAddressRoute from "./resources/userAddress/useAddressRoute.js";
//business_Type //business_Type
@ -83,9 +83,9 @@ app.use("/api", ProductRouter);
app.use("/api/category", categoryRoute); app.use("/api/category", categoryRoute);
app.use("/api/banner", bannerRoute); app.use("/api/banner", bannerRoute);
// registration image // registration image
app.use('/api/registerImage', RegistrationImageRoute) app.use("/api/registerImage", RegistrationImageRoute);
app.use('/api/loginImage', loginImageRoute) app.use("/api/loginImage", loginImageRoute);
app.use('/api/shopImage', shopImageRoute) app.use("/api/shopImage", shopImageRoute);
// Content // Content
app.use("/api/content", ContentRoute); app.use("/api/content", ContentRoute);
// User Address // User Address

View File

@ -17,7 +17,7 @@ export const addBanner = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath, 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( const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath, bannerImag.tempFilePath,
{ {
folder: "jatinMor/banner", folder: "GetSygnal/banner",
} }
); );
const update = await BannerModel.findOneAndUpdate( const update = await BannerModel.findOneAndUpdate(

View File

@ -16,7 +16,7 @@ export const addCategory = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
categoryImage.tempFilePath, 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( const result = await cloudinary.v2.uploader.upload(
categoryImag.tempFilePath, categoryImag.tempFilePath,
{ {
folder: "jatinMor/category", folder: "GetSygnal/category",
} }
); );
const update = await CategoryModel.findOneAndUpdate( const update = await CategoryModel.findOneAndUpdate(

View File

@ -41,7 +41,7 @@ const imageUpload = multer({ storage: imageStorage }).any();
// const result = await cloudinary.v2.uploader.upload( // const result = await cloudinary.v2.uploader.upload(
// designImage.tempFilePath, // 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( const result = await cloudinary.v2.uploader.upload(
designImage.tempFilePath, designImage.tempFilePath,
{ {
folder: "jatinMor/design", folder: "GetSygnal/design",
} }
); );
const update = await DesignModel.findOneAndUpdate( const update = await DesignModel.findOneAndUpdate(

View File

@ -18,7 +18,7 @@ export const addImage = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath, 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( // const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath, // 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( const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath, bannerImag.tempFilePath,
{ {
folder: "jatinMor/loginImage", folder: "GetSygnal/loginImage",
} }
); );
console.log("result", result); console.log("result", result);

View File

@ -24,7 +24,7 @@ export const createProduct = async (req, res) => {
const imagesLinks = []; const imagesLinks = [];
for (let i = 0; i < images.length; i++) { for (let i = 0; i < images.length; i++) {
const result = await cloudinary.v2.uploader.upload(images[i], { const result = await cloudinary.v2.uploader.upload(images[i], {
folder: "jatinMor/product", folder: "GetSygnal/product",
}); });
imagesLinks.push({ imagesLinks.push({
@ -112,7 +112,7 @@ export const updateProduct = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
newuploadImages[i].tempFilePath, newuploadImages[i].tempFilePath,
{ {
folder: "jatinMor/product", folder: "GetSygnal/product",
} }
); );

View File

@ -18,7 +18,7 @@ export const addImage = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath, bannerImage.tempFilePath,
{ {
folder: "jatinMor/registrationImage", folder: "GetSygnal/registrationImage",
} }
); );
@ -84,7 +84,7 @@ export const getImage = async (req, res) => {
// const result = await cloudinary.v2.uploader.upload( // const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath, // bannerImag.tempFilePath,
// { // {
// folder: "jatinMor/registrationImage", // folder: "GetSygnal/registrationImage",
// } // }
// ); // );
@ -139,21 +139,20 @@ export const updateImage = async (req, res) => {
// find the document with the id to delete the image from cloudinary // find the document with the id to delete the image from cloudinary
if (olderImage) { if (olderImage) {
const deletefromCloudinary = await RegistrationImageModel.findOne({
const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id }); _id: _id,
});
// console.log("deletefromCloudinary", deletefromCloudinary) // console.log("deletefromCloudinary", deletefromCloudinary)
const deleteresponse = await cloudinary.v2.uploader.destroy( const deleteresponse = await cloudinary.v2.uploader.destroy(
deletefromCloudinary.image.public_id deletefromCloudinary.image.public_id
); );
if (deleteresponse) { if (deleteresponse) {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath, bannerImag.tempFilePath,
{ {
folder: "jatinMor/registrationImage", folder: "GetSygnal/registrationImage",
} }
); );
console.log("result", result); console.log("result", result);
@ -196,13 +195,17 @@ export const deleteImage = async (req, res) => {
return res.status(404).json({ error: "Can not find the document " }); return res.status(404).json({ error: "Can not find the document " });
} }
const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id }); const deletefromCloudinary = await RegistrationImageModel.findOne({
_id: _id,
});
// console.log(deletefromCloudinary); // console.log(deletefromCloudinary);
const deleteresponse = await cloudinary.v2.uploader.destroy( const deleteresponse = await cloudinary.v2.uploader.destroy(
deletefromCloudinary.image.public_id deletefromCloudinary.image.public_id
); );
if (deleteresponse) { if (deleteresponse) {
const deleteBanner = await RegistrationImageModel.findOneAndDelete({ _id: _id }); const deleteBanner = await RegistrationImageModel.findOneAndDelete({
_id: _id,
});
if (!deleteBanner) { if (!deleteBanner) {
return res.status(404).json({ return res.status(404).json({
error: "Can not find the document with the provided id to delete ", error: "Can not find the document with the provided id to delete ",

View File

@ -3,8 +3,6 @@ import mongoose from "mongoose";
import cloudinary from "../../Utils/cloudinary.js"; import cloudinary from "../../Utils/cloudinary.js";
import { ShopPageImageModel } from "./ShopPageImageModel.js"; import { ShopPageImageModel } from "./ShopPageImageModel.js";
// Add new Category // Add new Category
export const addImage = async (req, res) => { export const addImage = async (req, res) => {
// const { bannerName } = req.body; // const { bannerName } = req.body;
@ -20,7 +18,7 @@ export const addImage = async (req, res) => {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImage.tempFilePath, bannerImage.tempFilePath,
{ {
folder: "jatinMor/shopImage", folder: "GetSygnal/shopImage",
} }
); );
@ -86,7 +84,7 @@ export const getImage = async (req, res) => {
// const result = await cloudinary.v2.uploader.upload( // const result = await cloudinary.v2.uploader.upload(
// bannerImag.tempFilePath, // bannerImag.tempFilePath,
// { // {
// folder: "jatinMor/shopImage", // folder: "GetSygnal/shopImage",
// } // }
// ); // );
@ -141,21 +139,20 @@ export const updateImage = async (req, res) => {
// find the document with the id to delete the image from cloudinary // find the document with the id to delete the image from cloudinary
if (olderImage) { if (olderImage) {
const deletefromCloudinary = await ShopPageImageModel.findOne({
const deletefromCloudinary = await ShopPageImageModel.findOne({ _id: _id }); _id: _id,
});
// console.log("deletefromCloudinary", deletefromCloudinary) // console.log("deletefromCloudinary", deletefromCloudinary)
const deleteresponse = await cloudinary.v2.uploader.destroy( const deleteresponse = await cloudinary.v2.uploader.destroy(
deletefromCloudinary.image.public_id deletefromCloudinary.image.public_id
); );
if (deleteresponse) { if (deleteresponse) {
const result = await cloudinary.v2.uploader.upload( const result = await cloudinary.v2.uploader.upload(
bannerImag.tempFilePath, bannerImag.tempFilePath,
{ {
folder: "jatinMor/shopImage", folder: "GetSygnal/shopImage",
} }
); );
console.log("result", result); console.log("result", result);
@ -204,7 +201,9 @@ export const deleteImage = async (req, res) => {
deletefromCloudinary.image.public_id deletefromCloudinary.image.public_id
); );
if (deleteresponse) { if (deleteresponse) {
const deleteBanner = await ShopPageImageModel.findOneAndDelete({ _id: _id }); const deleteBanner = await ShopPageImageModel.findOneAndDelete({
_id: _id,
});
if (!deleteBanner) { if (!deleteBanner) {
return res.status(404).json({ return res.status(404).json({
error: "Can not find the document with the provided id to delete ", error: "Can not find the document with the provided id to delete ",

View File

@ -1,91 +1,84 @@
import cloudinary from "../../Utils/cloudinary.js"; import cloudinary from "../../Utils/cloudinary.js";
import { Testimonial } from "./TestimonialModel.js" import { Testimonial } from "./TestimonialModel.js";
export const AddNewTestimonial = async (req, res) => { export const AddNewTestimonial = async (req, res) => {
try { try {
if (!req?.user) return res.status(400).json({ message: "please login !" }); if (!req?.user) return res.status(400).json({ message: "please login !" });
// console.log(req?.user) // console.log(req?.user)
if (req.files) { if (req.files) {
let getImg = req.files.image let getImg = req.files.image;
const result = await cloudinary.v2.uploader.upload(getImg?.tempFilePath, { const result = await cloudinary.v2.uploader.upload(getImg?.tempFilePath, {
folder: "jatinMor/Testimonial", folder: "GetSygnal/Testimonial",
}) });
let simage = { let simage = {
public_id: result.public_id, public_id: result.public_id,
url: result.secure_url, url: result.secure_url,
} };
req.body.image = simage req.body.image = simage;
} }
req.body.user = req.user._id req.body.user = req.user._id;
const testimonial = await Testimonial.create(req.body); const testimonial = await Testimonial.create(req.body);
res.status(201).json({ res.status(201).json({
success: true, success: true,
testimonial, testimonial,
message: 'Testimonial Added', message: "Testimonial Added",
}); });
} catch (error) { } catch (error) {
res.status(500).json({ res.status(500).json({
success: false, success: false,
message: error.message ? error.message : 'Something went Wrong', message: error.message ? error.message : "Something went Wrong",
}); });
} }
} };
export const FindAllTestimonial = async (req, res) => { export const FindAllTestimonial = async (req, res) => {
try { try {
if (!req?.user) return res.status(400).json({ message: "please login !" }); if (!req?.user) return res.status(400).json({ message: "please login !" });
// console.log(req?.user) // console.log(req?.user)
const testimonial = await Testimonial.find().sort({ createdAt: -1 }); const testimonial = await Testimonial.find().sort({ createdAt: -1 });
if (testimonial) { if (testimonial) {
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
testimonial, testimonial,
message: 'Fetched All Testimonial', message: "Fetched All Testimonial",
}); });
} } else {
else {
return res.status(404).json({ return res.status(404).json({
success: true, success: true,
message: 'No Testimonial till Now', message: "No Testimonial till Now",
}); });
} }
} catch (error) { } catch (error) {
res.status(500).json({ res.status(500).json({
success: false, success: false,
message: error.message ? error.message : 'Something went Wrong', message: error.message ? error.message : "Something went Wrong",
}); });
} }
} };
export const FindOneTestimonial = async (req, res) => { export const FindOneTestimonial = async (req, res) => {
try { try {
if (!req?.user) return res.status(400).json({ message: "please login !" }); if (!req?.user) return res.status(400).json({ message: "please login !" });
// console.log(req?.user) // console.log(req?.user)
if (!req.params.id) return res.status(400).json({ message: "please give ID !" }); if (!req.params.id)
return res.status(400).json({ message: "please give ID !" });
const testimonial = await Testimonial.findById(req.params.id); const testimonial = await Testimonial.findById(req.params.id);
if (testimonial) { if (testimonial) {
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
testimonial, testimonial,
message: 'Fetched Testimonial', message: "Fetched Testimonial",
}); });
} }
} catch (error) { } catch (error) {
res.status(500).json({ res.status(500).json({
success: false, success: false,
message: error.message ? error.message : 'Something went Wrong', message: error.message ? error.message : "Something went Wrong",
}); });
} }
} };

View File

@ -121,7 +121,7 @@ export const forgotPassword = async (req, res, next) => {
from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender 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: <br/> <strong> ${passwords}</strong><br/><br/>If you have not requested this email then, please ignore it.`, html: `your new password is: <br/> <strong> ${passwords}</strong><br/><br/>If you have not requested this email then, please ignore it.`,
}); });

View File

@ -1,12 +1,11 @@
import dotenv from "dotenv";
import dotenv from 'dotenv' dotenv.config();
dotenv.config() import app from "./app.js";
import app from "./app.js" import connectDatabase from "./database/db.js";
import connectDatabase from "./database/db.js" import cloudinary from "cloudinary";
import cloudinary from "cloudinary"
// Connecting to database // Connecting to database
connectDatabase() connectDatabase();
//console.log(process.env.CLOUDINARY_API_KEY) //console.log(process.env.CLOUDINARY_API_KEY)
//cloudenary uses //cloudenary uses
@ -31,9 +30,8 @@ app.get("/", (req, res) => {
// } // }
//<---------deployement-------------> //<---------deployement------------->
const server = app.listen(process.env.PORT, () => { 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 // Unhandled Promise Rejection
// process.on("unhandledRejection", (err) => { // process.on("unhandledRejection", (err) => {