From f7cfe625fda93a9174d07273fb925d17f9bf64c2 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Tue, 22 Apr 2025 13:01:40 +0330 Subject: [PATCH] ADD: indexAllTransactions and searchTransactions handlers --- .../transaction/transactionController.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/components/transaction/transactionController.js b/components/transaction/transactionController.js index d5e6f49..a4199f6 100644 --- a/components/transaction/transactionController.js +++ b/components/transaction/transactionController.js @@ -1,6 +1,27 @@ const catchAsync = require('../../globalErrorHandler/catchAsync') const transactionService = require('./transactionService') +exports.searchTransactions = catchAsync(async (req, res, next) => { + const { facets, transactions, totalCount, pagesCount } = await transactionService.searchTransactions(req.query) + + res.status(200).json({ + status: 'success', + facets, + transactions, + totalCount, + pagesCount, + }) +}) + +exports.indexAllTransactions = catchAsync(async (req, res, next) => { + const { indexedCount } = await transactionService.indexAllTransactions() + + res.status(200).json({ + status: 'success', + indexedCount, + }) +}) + exports.createTransaction = catchAsync(async (req, res, next) => { const transactions = await transactionService.createTransaction(req.body)