2025-03-25 14:47:54 -06:00
|
|
|
// routes/product.js
|
2025-03-19 02:09:30 -06:00
|
|
|
const express = require("express");
|
2025-03-24 23:04:12 -06:00
|
|
|
const {
|
2025-04-12 13:10:17 -06:00
|
|
|
addFavorite,
|
|
|
|
|
getFavorites,
|
2025-04-13 12:52:21 -06:00
|
|
|
removeFavorite,
|
2025-03-24 23:04:12 -06:00
|
|
|
getAllProducts,
|
|
|
|
|
getProductById,
|
2025-04-18 20:25:02 -06:00
|
|
|
addProduct,
|
2025-04-20 07:48:20 -06:00
|
|
|
removeProduct,
|
|
|
|
|
getProductWithPagination,
|
2025-04-20 21:52:15 -06:00
|
|
|
myProduct,
|
2025-04-20 17:46:00 -06:00
|
|
|
updateProduct,
|
2025-03-24 23:04:12 -06:00
|
|
|
} = require("../controllers/product");
|
2025-03-19 02:09:30 -06:00
|
|
|
const router = express.Router();
|
|
|
|
|
|
2025-03-25 14:47:54 -06:00
|
|
|
// Add detailed logging middleware
|
|
|
|
|
router.use((req, res, next) => {
|
|
|
|
|
console.log(`Incoming ${req.method} request to ${req.path}`);
|
|
|
|
|
next();
|
|
|
|
|
});
|
2025-03-19 02:09:30 -06:00
|
|
|
|
2025-04-12 13:10:17 -06:00
|
|
|
router.post("/addFavorite", addFavorite);
|
|
|
|
|
router.post("/getFavorites", getFavorites);
|
2025-04-13 12:52:21 -06:00
|
|
|
router.post("/delFavorite", removeFavorite);
|
2025-04-12 13:10:17 -06:00
|
|
|
|
2025-04-20 17:46:00 -06:00
|
|
|
router.post("/delProduct", removeProduct);
|
2025-04-19 10:22:16 -06:00
|
|
|
router.post("/myProduct", myProduct);
|
2025-04-18 20:25:02 -06:00
|
|
|
router.post("/addProduct", addProduct);
|
2025-04-12 13:10:17 -06:00
|
|
|
router.get("/getProduct", getAllProducts);
|
2025-04-20 07:48:20 -06:00
|
|
|
|
|
|
|
|
//Remove product
|
|
|
|
|
router.delete("/:id", removeProduct);
|
|
|
|
|
//Get products with pagination
|
|
|
|
|
router.get("/getProductWithPagination", getProductWithPagination);
|
|
|
|
|
|
2025-03-25 14:47:54 -06:00
|
|
|
router.get("/:id", getProductById); // Simplified route
|
2025-03-24 23:04:12 -06:00
|
|
|
|
2025-04-20 17:46:00 -06:00
|
|
|
router.put("/update/:productId", updateProduct);
|
|
|
|
|
|
2025-03-19 02:09:30 -06:00
|
|
|
module.exports = router;
|