make it betterlkjkfkffd

This commit is contained in:
pawan-dot 2022-06-23 14:03:59 +05:30
parent 22fe368d49
commit 7c3cd09564
57 changed files with 16 additions and 17 deletions

View File

@ -4,10 +4,8 @@ import cloudinary from "cloudinary";
export const createOffer = async (req, res) => { export const createOffer = async (req, res) => {
try { try {
// console.log(req.body)
const files = req.files.image; const files = req.files.image;
// console.log(req.body)
// console.log(files)
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
folder: "cmp/image", folder: "cmp/image",
}, },
@ -25,7 +23,6 @@ export const createOffer = async (req, res) => {
bisunessName bisunessName
}); });
// console.log(data)
res.status(201).json({ res.status(201).json({
success: true, success: true,
msg: " create Offer Successfully!!", msg: " create Offer Successfully!!",
@ -44,7 +41,6 @@ export const getAllOffer = async (req, res) => {
try { try {
const offer = await Offers.find(); const offer = await Offers.find();
// console.log(category)
res.status(200).json({ res.status(200).json({
success: true, success: true,
msg: " fetch All Offer Successfully!!", msg: " fetch All Offer Successfully!!",
@ -63,14 +59,13 @@ export const getOneOffer = async (req, res) => {
try { try {
const offer = await Offers.findById(req.params.id); const offer = await Offers.findById(req.params.id);
// console.log(category)
res.status(200).json({ res.status(200).json({
success: true, success: true,
msg: " fetch Successfully!!", msg: " fetch Successfully!!",
offer, offer,
}); });
} catch (error) { } catch (error) {
// console.log(error)
res.status(500).json({ res.status(500).json({
success: false, success: false,
msg: "Failled to fetch !!" msg: "Failled to fetch !!"
@ -95,15 +90,12 @@ export const updateOffer = async (req, res) => {
const getOffer = await Offers.findById(req.params.id); const getOffer = await Offers.findById(req.params.id);
const imageId = getOffer.image.public_id; const imageId = getOffer.image.public_id;
// console.log(imageId)
//delete image from claudinary
await cloudinary.uploader.destroy(imageId) await cloudinary.uploader.destroy(imageId)
// await cloudinary.uploader.destroy(imageId, function (result) { console.log(result) });
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
folder: "image", folder: "image",
}, },
function (error, result) { (result, error) }); function (error, result) { (result, error) });
// console.log(myCloud)
newOfferData.image = { newOfferData.image = {
public_id: myCloud.public_id, public_id: myCloud.public_id,
url: myCloud.secure_url, url: myCloud.secure_url,
@ -114,8 +106,7 @@ export const updateOffer = async (req, res) => {
const ModifyOffer = await Offers.findByIdAndUpdate(req.params.id, newOfferData, const ModifyOffer = await Offers.findByIdAndUpdate(req.params.id, newOfferData,
{ new: true } { new: true }
// runValidators: true,
// useFindAndModify: false,
); );
res.status(200).json({ res.status(200).json({

View File

@ -8,13 +8,13 @@ export const createBanner = async (req, res) => {
try { try {
const files = req.files.image; const files = req.files.image;
// console.log(files) // console.log(files)
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
folder: "cmp/image", folder: "cmp/image",
}, },
function (error, result) { (result, error) }); function (error, result) { (result, error) });
const { title, section, startDate, endDate, subTitle } = req.body; const { title, section, startDate, endDate, subTitle } = req.body;
const data = await Banners.create({ const data = await Banners.create({
title, title,
subTitle, subTitle,
@ -27,12 +27,14 @@ export const createBanner = async (req, res) => {
endDate endDate
}); });
res.status(201).json({ res.status(201).json({
success: true, success: true,
msg: " create Banner Successfully!!", msg: " create Banner Successfully!!",
data, data,
}); });
} catch (error) { } catch (error) {
// console.log(error)
res.status(500).json({ res.status(500).json({
success: false, success: false,
msg: "Failled to create Banner !!" msg: "Failled to create Banner !!"

View File

@ -5,8 +5,14 @@ import ErrorHander from "../Utils/errorhander.js"
export const isAuthenticatedUser = async (req, res, next) => { export const isAuthenticatedUser = async (req, res, next) => {
try { try {
// const { token } = req.cookies; // const { token } = req.cookies;
const getToken = req.headers;
const getToken = req.headers;
if (!getToken) {
return res.status(400).json({
success: false,
message: "Login to Access this resource",
});
}
// // console.log(getToken.authorization) // // console.log(getToken.authorization)
// console.log(getToken) // console.log(getToken)
@ -17,7 +23,7 @@ export const isAuthenticatedUser = async (req, res, next) => {
if (!fronttoken) { if (!fronttoken) {
return res.status(400).json({ return res.status(400).json({
success: false, success: false,
message: "Login to Access this resource", message: "Login to Access this resource token",
}); });
} }
// if (!fronttoken) { // if (!fronttoken) {

View File

@ -7,7 +7,7 @@ import {
getOneBanner getOneBanner
} from "../controllers/bannerController.js" } from "../controllers/bannerController.js"
const router = express.Router(); const router = express.Router();
import { isAuthenticatedUser, authorizeRoles } from "../middlewares/auth.js"
router.route("/banner/create/").post(createBanner) router.route("/banner/create/").post(createBanner)
router.route("/banner/getAll/").get(getAllBanner) router.route("/banner/getAll/").get(getAllBanner)
router.route("/banner/getOne/:id").get(getOneBanner) router.route("/banner/getOne/:id").get(getOneBanner)

BIN
tmp/tmp-1-1655970064628 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655970163588 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655970446002 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
tmp/tmp-1-1655971046217 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
tmp/tmp-1-1655971805691 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972354067 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972492909 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972563013 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972581720 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972644905 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972775829 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972888130 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655972990452 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-1-1655973060170 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-10-1655972743712 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-11-1655972744922 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-12-1655972746446 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-13-1655972747702 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-14-1655972748819 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-15-1655972750007 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-16-1655972751424 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-17-1655972752626 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655970253011 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
tmp/tmp-2-1655970836223 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
tmp/tmp-2-1655971379121 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

BIN
tmp/tmp-2-1655972494837 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972565632 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972583625 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972646309 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972779981 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972890321 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-2-1655972992160 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972496179 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972566968 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972585061 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972647641 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972819196 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-3-1655972931608 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-4-1655972497375 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-4-1655972586262 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-4-1655972648850 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-4-1655972933242 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-5-1655972505559 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-5-1655972587344 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-5-1655972649948 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-5-1655972934690 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-6-1655972588413 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-6-1655972651087 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-6-1655972936218 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-7-1655972652262 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-7-1655972937734 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-8-1655972653368 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
tmp/tmp-9-1655972741391 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB