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 {
|
|
|
|
|
addToFavorite,
|
|
|
|
|
getAllProducts,
|
|
|
|
|
getProductById,
|
|
|
|
|
} = 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-03-25 14:47:54 -06:00
|
|
|
router.post("/add_fav_product", addToFavorite);
|
2025-03-19 02:09:30 -06:00
|
|
|
router.get("/get_product", getAllProducts);
|
2025-03-25 14:47:54 -06:00
|
|
|
router.get("/:id", getProductById); // Simplified route
|
2025-03-24 23:04:12 -06:00
|
|
|
|
2025-03-19 02:09:30 -06:00
|
|
|
module.exports = router;
|