Skip to content

Commit

Permalink
supply_route
Browse files Browse the repository at this point in the history
  • Loading branch information
IkkiOcean committed Nov 9, 2024
1 parent 7213960 commit 2d939fd
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions backend/routes/sub-routes/supplierRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const express = require("express");
const router = express.Router();
const supplierController = require("../controllers/supplierController");
const productController = require("../controllers/productController");
const supplierSearchController = require("../controllers/supplierSearchController");
const supplierFilterController = require("../controllers/supplierFilterController");
const validateSupplierData = require("../middlewares/validationMiddleware");
const isAdmin = require("../middlewares/authMiddleware");

// Routes for suppliers
router.post(
"/api/suppliers",
isAdmin,
validateSupplierData,
supplierController.createSupplier
); // Admin only
router.get("/api/suppliers", supplierController.getAllSuppliers);
router.get("/api/suppliers/:id", supplierController.getSupplierById);
router.put(
"/api/suppliers/:id",
isAdmin,
validateSupplierData,
supplierController.updateSupplier
); // Admin only
router.delete("/api/suppliers/:id", isAdmin, supplierController.deleteSupplier); // Admin only

// Routes for managing products supplied by a supplier
router.post(
"/api/suppliers/:id/products",
isAdmin,
productController.addProductToSupplier
); // Admin only
router.delete(
"/api/suppliers/:id/products",
isAdmin,
productController.removeProductFromSupplier
); // Admin only
router.get(
"/api/suppliers/:id/products",
productController.getProductsSupplied
);

// Routes for searching and filtering suppliers
router.get("/api/suppliers/search", supplierSearchController.searchSuppliers);
router.get(
"/api/suppliers/status/:status",
supplierFilterController.getSuppliersByStatus
);

module.exports = router;

0 comments on commit 2d939fd

Please sign in to comment.