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, + }) +})