Skip to content

Commit

Permalink
remove auth check for seraching product
Browse files Browse the repository at this point in the history
  • Loading branch information
soleil00 committed Jul 2, 2024
1 parent 325db6b commit 3cad6b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/coverage
/uploads
/.vscode
/dist
39 changes: 23 additions & 16 deletions src/routes/productsRoute.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
import { Router } from "express";
import { upload } from "../utils/uploadImages";
import { fetchProducts, addProducts, fetchSingleProduct, productsUpdate, removeProducts, productAvailability,searchProductController} from "../controllers/productControllers";
import {
fetchProducts,
addProducts,
fetchSingleProduct,
productsUpdate,
removeProducts,
productAvailability,
searchProductController,
} from "../controllers/productControllers";
import { validateSchema } from "../middlewares/validator";
import { productDataSchema } from "../schemas/productSchema";
import { isAseller } from "../middlewares/sellerAuth";
import { isLoggedIn } from "../middlewares/isLoggedIn";
import { isCategoryExist } from "../middlewares/isCategoryExist";
import { addReviewController, deleteReviewController, getreviewController, updateReviewController} from "../controllers/productControllers"
import { addReviewController, deleteReviewController, getreviewController, updateReviewController } from "../controllers/productControllers";
import { addReviewValidate, updateReviewValidate } from "../schemas/review";
import { hasPurchasedProduct } from "../middlewares/hasPurchased";
import { isPasswordOutOfDate } from "../middlewares/isPasswordOutOfDate";
import { getAds } from "../controllers/adsController";

const productsRouter = Router();
productsRouter.get("/search",isPasswordOutOfDate, searchProductController)
productsRouter.get('/ads', getAds);
productsRouter.get("/search", searchProductController);
productsRouter.get("/ads", getAds);

productsRouter.get("/",fetchProducts);
productsRouter.get("/:id",fetchSingleProduct);
productsRouter.post("/",isLoggedIn,isPasswordOutOfDate,isAseller,upload.array('images'),
validateSchema(productDataSchema),isCategoryExist,addProducts);
productsRouter.patch("/:id",isLoggedIn,isPasswordOutOfDate,isAseller,upload.array('images'),productsUpdate);
productsRouter.patch("/:id/status",isLoggedIn,isPasswordOutOfDate,isAseller,productAvailability);
productsRouter.delete("/:id",isLoggedIn,isPasswordOutOfDate,isAseller,removeProducts);
productsRouter.get("/", fetchProducts);
productsRouter.get("/:id", fetchSingleProduct);
productsRouter.post("/", isLoggedIn, isPasswordOutOfDate, isAseller, upload.array("images"), validateSchema(productDataSchema), isCategoryExist, addProducts);
productsRouter.patch("/:id", isLoggedIn, isPasswordOutOfDate, isAseller, upload.array("images"), productsUpdate);
productsRouter.patch("/:id/status", isLoggedIn, isPasswordOutOfDate, isAseller, productAvailability);
productsRouter.delete("/:id", isLoggedIn, isPasswordOutOfDate, isAseller, removeProducts);

productsRouter.get("/:pid/reviews", getreviewController)
productsRouter.post("/:pid/reviews",isLoggedIn,isPasswordOutOfDate,validateSchema(addReviewValidate), hasPurchasedProduct, addReviewController)
productsRouter.delete("/:pid/reviews", isLoggedIn,isPasswordOutOfDate, deleteReviewController)
productsRouter.patch("/:pid/reviews", isLoggedIn,isPasswordOutOfDate, validateSchema(updateReviewValidate), updateReviewController)
export default productsRouter;
productsRouter.get("/:pid/reviews", getreviewController);
productsRouter.post("/:pid/reviews", isLoggedIn, isPasswordOutOfDate, validateSchema(addReviewValidate), hasPurchasedProduct, addReviewController);
productsRouter.delete("/:pid/reviews", isLoggedIn, isPasswordOutOfDate, deleteReviewController);
productsRouter.patch("/:pid/reviews", isLoggedIn, isPasswordOutOfDate, validateSchema(updateReviewValidate), updateReviewController);
export default productsRouter;

0 comments on commit 3cad6b5

Please sign in to comment.