From 6d2f736541e8f04c82f6df9b26b4dfffc56715b2 Mon Sep 17 00:00:00 2001 From: aruhani <163067503+aruhani@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:52:28 -0600 Subject: [PATCH] Updated transaction route file --- backend/routes/transaction.js | 53 ++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/backend/routes/transaction.js b/backend/routes/transaction.js index ba84a6a..9d0df2f 100644 --- a/backend/routes/transaction.js +++ b/backend/routes/transaction.js @@ -1,6 +1,45 @@ +// // routes/transaction.js +// const express = require("express"); +// const txCtrl = require("../controllers/transaction"); // <— grab the module +// const router = express.Router(); + +// // logging middleware +// router.use((req, res, next) => { +// console.log(`Incoming ${req.method} ${req.originalUrl}`); +// next(); +// }); + +// // Create a new transaction +// router.post("/createTransaction", txCtrl.createTransaction); + +// // Get all transactions for a specific product +// router.get("/getTransactionsByProduct/:productID", txCtrl.getTransactionsByProduct); + +// // Get all transactions for a specific user +// router.post("/getTransactionsByUser", txCtrl.getTransactionsByUser); + +// // Get all transactions in the system +// router.post("/getAllTransactions", txCtrl.getAllTransactions); + +// // Update payment status on a transaction +// router.patch("/updatePaymentStatus", txCtrl.updatePaymentStatus); + +// // Delete a transaction +// router.delete("/deleteTransaction", txCtrl.deleteTransaction); + +// module.exports = router; + + // routes/transaction.js const express = require("express"); -const txCtrl = require("../controllers/transaction"); // <— grab the module +const { + createTransaction, + getTransactionsByProduct, + getTransactionsByUser, + getAllTransactions, + updatePaymentStatus, + deleteTransaction, +} = require("../controllers/transaction"); const router = express.Router(); // logging middleware @@ -10,21 +49,21 @@ router.use((req, res, next) => { }); // Create a new transaction -router.post("/createTransaction", txCtrl.createTransaction); +router.post("/createTransaction", createTransaction); // Get all transactions for a specific product -router.get("/getTransactionsByProduct/:productID", txCtrl.getTransactionsByProduct); +router.get("/getTransactionsByProduct/:productID", getTransactionsByProduct); // Get all transactions for a specific user -router.post("/getTransactionsByUser", txCtrl.getTransactionsByUser); +router.post("/getTransactionsByUser", getTransactionsByUser); // Get all transactions in the system -router.post("/getAllTransactions", txCtrl.getAllTransactions); +router.post("/getAllTransactions", getAllTransactions); // Update payment status on a transaction -router.patch("/updatePaymentStatus", txCtrl.updatePaymentStatus); +router.patch("/updatePaymentStatus", updatePaymentStatus); // Delete a transaction -router.delete("/deleteTransaction", txCtrl.deleteTransaction); +router.delete("/deleteTransaction", deleteTransaction); module.exports = router;