fff
This commit is contained in:
parent
1d885ea074
commit
c999f1bf81
22
.env
22
.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"
|
@ -1,20 +1,17 @@
|
||||
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,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const storage = new CloudinaryStorage({
|
||||
cloudinary: cloudinary,
|
||||
params: {
|
||||
folder: "Atp",
|
||||
folder: "GetSygnal",
|
||||
},
|
||||
});
|
||||
|
||||
@ -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(new Error("File type not supported!"), false);
|
||||
return;
|
||||
}
|
||||
cb(null, true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default cloudinary;
|
12
app.js
12
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
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -18,7 +18,7 @@ export const addImage = async (req, res) => {
|
||||
const result = await cloudinary.v2.uploader.upload(
|
||||
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(
|
||||
// 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
|
||||
|
||||
if (olderImage) {
|
||||
|
||||
const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id });
|
||||
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",
|
||||
folder: "GetSygnal/registrationImage",
|
||||
}
|
||||
);
|
||||
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 " });
|
||||
}
|
||||
|
||||
const deletefromCloudinary = await RegistrationImageModel.findOne({ _id: _id });
|
||||
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 });
|
||||
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 ",
|
||||
|
@ -3,8 +3,6 @@ import mongoose from "mongoose";
|
||||
import cloudinary from "../../Utils/cloudinary.js";
|
||||
import { ShopPageImageModel } from "./ShopPageImageModel.js";
|
||||
|
||||
|
||||
|
||||
// Add new Category
|
||||
export const addImage = async (req, res) => {
|
||||
// const { bannerName } = req.body;
|
||||
@ -20,7 +18,7 @@ export const addImage = async (req, res) => {
|
||||
const result = await cloudinary.v2.uploader.upload(
|
||||
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(
|
||||
// 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
|
||||
|
||||
if (olderImage) {
|
||||
|
||||
const deletefromCloudinary = await ShopPageImageModel.findOne({ _id: _id });
|
||||
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",
|
||||
folder: "GetSygnal/shopImage",
|
||||
}
|
||||
);
|
||||
console.log("result", result);
|
||||
@ -204,7 +201,9 @@ export const deleteImage = async (req, res) => {
|
||||
deletefromCloudinary.image.public_id
|
||||
);
|
||||
if (deleteresponse) {
|
||||
const deleteBanner = await ShopPageImageModel.findOneAndDelete({ _id: _id });
|
||||
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 ",
|
||||
|
@ -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)
|
||||
|
||||
if (req.files) {
|
||||
let getImg = req.files.image
|
||||
let getImg = req.files.image;
|
||||
const result = await cloudinary.v2.uploader.upload(getImg?.tempFilePath, {
|
||||
folder: "jatinMor/Testimonial",
|
||||
})
|
||||
folder: "GetSygnal/Testimonial",
|
||||
});
|
||||
|
||||
let simage = {
|
||||
public_id: result.public_id,
|
||||
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);
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
testimonial,
|
||||
message: 'Testimonial Added',
|
||||
message: "Testimonial Added",
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message ? error.message : 'Something went Wrong',
|
||||
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)
|
||||
|
||||
|
||||
const testimonial = await Testimonial.find().sort({ createdAt: -1 });
|
||||
if (testimonial) {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
testimonial,
|
||||
message: 'Fetched All Testimonial',
|
||||
message: "Fetched All Testimonial",
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return res.status(404).json({
|
||||
success: true,
|
||||
|
||||
message: 'No Testimonial till Now',
|
||||
message: "No Testimonial till Now",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message ? error.message : 'Something went Wrong',
|
||||
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 !" });
|
||||
|
||||
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',
|
||||
message: "Fetched Testimonial",
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message ? error.message : 'Something went Wrong',
|
||||
message: error.message ? error.message : "Something went Wrong",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -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: <br/> <strong> ${passwords}</strong><br/><br/>If you have not requested this email then, please ignore it.`,
|
||||
});
|
||||
|
||||
|
18
server.js
18
server.js
@ -1,12 +1,11 @@
|
||||
|
||||
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
|
||||
@ -31,9 +30,8 @@ app.get("/", (req, res) => {
|
||||
// }
|
||||
//<---------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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user