make it betterlkjkfkffd
@ -4,10 +4,8 @@ import cloudinary from "cloudinary";
|
||||
export const createOffer = async (req, res) => {
|
||||
|
||||
try {
|
||||
// console.log(req.body)
|
||||
const files = req.files.image;
|
||||
// console.log(req.body)
|
||||
// console.log(files)
|
||||
|
||||
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||
folder: "cmp/image",
|
||||
},
|
||||
@ -25,7 +23,6 @@ export const createOffer = async (req, res) => {
|
||||
bisunessName
|
||||
|
||||
});
|
||||
// console.log(data)
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
msg: " create Offer Successfully!!",
|
||||
@ -44,7 +41,6 @@ export const getAllOffer = async (req, res) => {
|
||||
|
||||
try {
|
||||
const offer = await Offers.find();
|
||||
// console.log(category)
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
msg: " fetch All Offer Successfully!!",
|
||||
@ -63,14 +59,13 @@ export const getOneOffer = async (req, res) => {
|
||||
|
||||
try {
|
||||
const offer = await Offers.findById(req.params.id);
|
||||
// console.log(category)
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
msg: " fetch Successfully!!",
|
||||
offer,
|
||||
});
|
||||
} catch (error) {
|
||||
// console.log(error)
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
msg: "Failled to fetch !!"
|
||||
@ -95,15 +90,12 @@ export const updateOffer = async (req, res) => {
|
||||
const getOffer = await Offers.findById(req.params.id);
|
||||
|
||||
const imageId = getOffer.image.public_id;
|
||||
// console.log(imageId)
|
||||
//delete image from claudinary
|
||||
|
||||
await cloudinary.uploader.destroy(imageId)
|
||||
// await cloudinary.uploader.destroy(imageId, function (result) { console.log(result) });
|
||||
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||
folder: "image",
|
||||
},
|
||||
function (error, result) { (result, error) });
|
||||
// console.log(myCloud)
|
||||
newOfferData.image = {
|
||||
public_id: myCloud.public_id,
|
||||
url: myCloud.secure_url,
|
||||
@ -114,8 +106,7 @@ export const updateOffer = async (req, res) => {
|
||||
const ModifyOffer = await Offers.findByIdAndUpdate(req.params.id, newOfferData,
|
||||
|
||||
{ new: true }
|
||||
// runValidators: true,
|
||||
// useFindAndModify: false,
|
||||
|
||||
);
|
||||
|
||||
res.status(200).json({
|
||||
|
@ -8,13 +8,13 @@ export const createBanner = async (req, res) => {
|
||||
try {
|
||||
const files = req.files.image;
|
||||
|
||||
|
||||
// console.log(files)
|
||||
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||
folder: "cmp/image",
|
||||
},
|
||||
function (error, result) { (result, error) });
|
||||
const { title, section, startDate, endDate, subTitle } = req.body;
|
||||
|
||||
const data = await Banners.create({
|
||||
title,
|
||||
subTitle,
|
||||
@ -27,12 +27,14 @@ export const createBanner = async (req, res) => {
|
||||
endDate
|
||||
|
||||
});
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
msg: " create Banner Successfully!!",
|
||||
data,
|
||||
});
|
||||
} catch (error) {
|
||||
// console.log(error)
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
msg: "Failled to create Banner !!"
|
||||
|
@ -5,8 +5,14 @@ import ErrorHander from "../Utils/errorhander.js"
|
||||
export const isAuthenticatedUser = async (req, res, next) => {
|
||||
try {
|
||||
// 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)
|
||||
|
||||
@ -17,7 +23,7 @@ export const isAuthenticatedUser = async (req, res, next) => {
|
||||
if (!fronttoken) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: "Login to Access this resource",
|
||||
message: "Login to Access this resource token",
|
||||
});
|
||||
}
|
||||
// if (!fronttoken) {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
getOneBanner
|
||||
} from "../controllers/bannerController.js"
|
||||
const router = express.Router();
|
||||
|
||||
import { isAuthenticatedUser, authorizeRoles } from "../middlewares/auth.js"
|
||||
router.route("/banner/create/").post(createBanner)
|
||||
router.route("/banner/getAll/").get(getAllBanner)
|
||||
router.route("/banner/getOne/:id").get(getOneBanner)
|
||||
|
BIN
tmp/tmp-1-1655970064628
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655970163588
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655970446002
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
tmp/tmp-1-1655971046217
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
tmp/tmp-1-1655971805691
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972354067
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972492909
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972563013
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972581720
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972644905
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972775829
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972888130
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655972990452
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1655973060170
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-10-1655972743712
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-11-1655972744922
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-12-1655972746446
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-13-1655972747702
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-14-1655972748819
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-15-1655972750007
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-16-1655972751424
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-17-1655972752626
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655970253011
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
tmp/tmp-2-1655970836223
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
tmp/tmp-2-1655971379121
Normal file
After Width: | Height: | Size: 620 KiB |
BIN
tmp/tmp-2-1655972494837
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972565632
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972583625
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972646309
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972779981
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972890321
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1655972992160
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972496179
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972566968
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972585061
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972647641
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972819196
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1655972931608
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-4-1655972497375
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-4-1655972586262
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-4-1655972648850
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-4-1655972933242
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-5-1655972505559
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-5-1655972587344
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-5-1655972649948
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-5-1655972934690
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-6-1655972588413
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-6-1655972651087
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-6-1655972936218
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-7-1655972652262
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-7-1655972937734
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-8-1655972653368
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-9-1655972741391
Normal file
After Width: | Height: | Size: 1.4 MiB |