Files
Campus-Plug/backend/routes/transaction.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

// routes/transaction.js
const express = require("express");
const {
2025-04-20 23:52:28 -06:00
createTransaction,
getTransactionsByProduct,
getTransactionsByUser,
getAllTransactions,
updatePaymentStatus,
deleteTransaction,
} = require("../controllers/transaction");
const router = express.Router();
// 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);
// Get all transactions for a specific product
2025-04-20 23:52:28 -06:00
router.get("/getTransactionsByProduct/:productID", getTransactionsByProduct);
// Get all transactions for a specific user
2025-04-20 23:52:28 -06:00
router.post("/getTransactionsByUser", getTransactionsByUser);
// Get all transactions in the system
2025-04-20 23:52:28 -06:00
router.post("/getAllTransactions", getAllTransactions);
// Update payment status on a transaction
2025-04-20 23:52:28 -06:00
router.patch("/updatePaymentStatus", updatePaymentStatus);
// Delete a transaction
2025-04-20 23:52:28 -06:00
router.delete("/deleteTransaction", deleteTransaction);
router.get("/getTransactions", getTransactionWithPagination);
router.delete("/:id", removeTransation);
module.exports = router;