Skip to content

Commit

Permalink
fixed category fetch allowong user to fetch availabe categories
Browse files Browse the repository at this point in the history
  • Loading branch information
soleil00 committed Jul 7, 2024
1 parent b54207b commit fa56e10
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/routes/categoriesRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import { Router } from "express";
import { upload } from "../utils/uploadImages";
import {
fetchCategories,
addCategories,
fetchSingleCategory,
categoriesUpdate,
removeCategories
} from "../controllers/categoriesControllers";
import { validateSchema } from "../middlewares/validator";
import { fetchCategories, addCategories, fetchSingleCategory, categoriesUpdate, removeCategories } from "../controllers/categoriesControllers";
import { validateSchema } from "../middlewares/validator";
import { categoriesDataSchema } from "../schemas/categorySchema";
import { isAseller } from "../middlewares/sellerAuth";
import { isLoggedIn } from "../middlewares/isLoggedIn";
import { isPasswordOutOfDate } from "../middlewares/isPasswordOutOfDate";
const categoriesRouter = Router();
categoriesRouter.get("/",isLoggedIn,isPasswordOutOfDate,isAseller,fetchCategories);
categoriesRouter.get("/:id",isLoggedIn,isPasswordOutOfDate,isAseller,fetchSingleCategory);
categoriesRouter.post("/",isLoggedIn,isPasswordOutOfDate,isAseller,upload.single('image'),validateSchema(categoriesDataSchema)
,addCategories);
categoriesRouter.patch("/:id",isAseller,isPasswordOutOfDate,upload.single('image'),categoriesUpdate);
categoriesRouter.delete("/:id",isLoggedIn,isPasswordOutOfDate,isAseller,removeCategories);
categoriesRouter.get("/", fetchCategories);
categoriesRouter.get("/:id", isLoggedIn, isPasswordOutOfDate, isAseller, fetchSingleCategory);
categoriesRouter.post("/", isLoggedIn, isPasswordOutOfDate, isAseller, upload.single("image"), validateSchema(categoriesDataSchema), addCategories);
categoriesRouter.patch("/:id", isAseller, isPasswordOutOfDate, upload.single("image"), categoriesUpdate);
categoriesRouter.delete("/:id", isLoggedIn, isPasswordOutOfDate, isAseller, removeCategories);

export default categoriesRouter;
export default categoriesRouter;

0 comments on commit fa56e10

Please sign in to comment.