From 9554f46f7ebb2ce2906d3cbf05f3c0431304fff2 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Thu, 17 Apr 2025 11:00:02 +0330 Subject: [PATCH] ADD: create and get a transaction handlers --- .../transaction/transactionController.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 components/transaction/transactionController.js diff --git a/components/transaction/transactionController.js b/components/transaction/transactionController.js new file mode 100644 index 0000000..60e4986 --- /dev/null +++ b/components/transaction/transactionController.js @@ -0,0 +1,22 @@ +const catchAsync = require('../../globalErrorHandler/catchAsync') +const transactionService = require('./transactionService') + +exports.createTransaction = catchAsync(async (req, res, next) => { + const transactions = await transactionService.createTransaction(req.body) + + res.status(200).json({ + status: 'success', + results: transactions.length, + data: transactions, + }) +}) + +exports.getUserTransaction = catchAsync(async (req, res, next) => { + const transactions = await transactionService.getUserTransaction(req.user._id) + + res.status(200).json({ + status: 'success', + results: transactions.length, + data: transactions, + }) +})