You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.9 KiB
JavaScript

const express = require("express");
const productControllers = require("../controllers/productControllers.js");
const auth = require("../auth.js");
// Router
const router = express.Router();
const {verify, verifyAdmin, verifyNonAdmin} = auth;
// Route for creating a product
router.post(`/create`, verify, verifyAdmin, productControllers.uploadImage, productControllers.createProduct);
// Route for check a existing product
router.post('/check-product-existence', verify, verifyAdmin, productControllers.isProductExisting);
// Route for retrieving all products
router.get(`/all`, verify, verifyAdmin, productControllers.getAllProducts);
// Route for retrieving all active products
router.get(`/`, productControllers.getAllActiveProducts);
// Route for searching products
router.post(`/search`, productControllers.searchProducts);
// Route for updating products
router.put(`/:productId`, verify, verifyAdmin, productControllers.updateProduct);
// Route for archiving a product
router.put(`/:productId/archive`, verify, verifyAdmin, productControllers.archiveProduct);
// Route for activate a product
router.put(`/:productId/activate`, verify, verifyAdmin, productControllers.activateProduct);
// Route to create an order || check-out
router.post(`/create-order`, verify, verifyNonAdmin, productControllers.createOrder);
// Route for getting the information of specific product
router.get("/:productId", productControllers.getProduct);
// Route for getting product name by id
router.post('/getProductName', productControllers.getProductName);
// My Cart
router.post('/add-to-cart', verify, verifyNonAdmin, productControllers.addProductToCart);
router.put('/update-quantity', productControllers.updateProductQuantity);
router.delete('/remove/:productId', verify, verifyNonAdmin, productControllers.removeProductFromCart);
router.get('/view-my-cart', verify, verifyNonAdmin, productControllers.getCartDetails);
module.exports = router;