From d9b87624747d78da4e798ee312710c2569a2655c Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Sun, 29 Dec 2024 20:29:17 +0330 Subject: [PATCH] ADD: get category tree handler function --- components/category/categoryController.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/category/categoryController.js b/components/category/categoryController.js index e26323e..6aef053 100644 --- a/components/category/categoryController.js +++ b/components/category/categoryController.js @@ -1,8 +1,15 @@ const catchAsync = require('../../globalErrorHandler/catchAsync') -const AppError = require('../../globalErrorHandler/AppError') -const Category = require('./categoryModel') const categoryService = require('./categoryService') +exports.getCategoryTree = catchAsync(async (req, res, next) => { + const categoryTree = await categoryService.getCategoryTree() + + res.status(200).json({ + status: 'success', + data: categoryTree, + }) +}) + exports.getAllCategories = catchAsync(async (req, res, next) => { const categories = await categoryService.getAllCategories()