2025-04-20 10:42:52 -06:00
|
|
|
// routes/transaction.js
|
2025-04-20 20:56:14 -06:00
|
|
|
const express = require("express");
|
|
|
|
|
const {
|
2025-04-20 23:52:28 -06:00
|
|
|
createTransaction,
|
|
|
|
|
getTransactionsByProduct,
|
|
|
|
|
getTransactionsByUser,
|
|
|
|
|
getAllTransactions,
|
|
|
|
|
updatePaymentStatus,
|
|
|
|
|
deleteTransaction,
|
2025-04-21 01:19:39 -06:00
|
|
|
getTransactionWithPagination,
|
|
|
|
|
removeTransation,
|
2025-04-20 20:56:14 -06:00
|
|
|
} = require("../controllers/transaction");
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
2025-04-20 10:42:52 -06:00
|
|
|
// logging middleware
|
|
|
|
|
router.use((req, res, next) => {
|
|
|
|
|
console.log(`Incoming ${req.method} ${req.originalUrl}`);
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Create a new transaction
|
2025-04-20 23:52:28 -06:00
|
|
|
router.post("/createTransaction", createTransaction);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
|
|
|
|
// Get all transactions for a specific product
|
2025-04-20 23:52:28 -06:00
|
|
|
router.get("/getTransactionsByProduct/:productID", getTransactionsByProduct);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
|
|
|
|
// Get all transactions for a specific user
|
2025-04-20 23:52:28 -06:00
|
|
|
router.post("/getTransactionsByUser", getTransactionsByUser);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
|
|
|
|
// Get all transactions in the system
|
2025-04-20 23:52:28 -06:00
|
|
|
router.post("/getAllTransactions", getAllTransactions);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
|
|
|
|
// Update payment status on a transaction
|
2025-04-20 23:52:28 -06:00
|
|
|
router.patch("/updatePaymentStatus", updatePaymentStatus);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
|
|
|
|
// Delete a transaction
|
2025-04-20 23:52:28 -06:00
|
|
|
router.delete("/deleteTransaction", deleteTransaction);
|
2025-04-20 10:42:52 -06:00
|
|
|
|
2025-04-20 20:56:14 -06:00
|
|
|
router.get("/getTransactions", getTransactionWithPagination);
|
|
|
|
|
router.delete("/:id", removeTransation);
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|