ADD: get category tree handler function

This commit is contained in:
MohammadHMazarei
2024-12-29 20:29:17 +03:30
parent 04ae44b3c9
commit d9b8762474
+9 -2
View File
@@ -1,8 +1,15 @@
const catchAsync = require('../../globalErrorHandler/catchAsync') const catchAsync = require('../../globalErrorHandler/catchAsync')
const AppError = require('../../globalErrorHandler/AppError')
const Category = require('./categoryModel')
const categoryService = require('./categoryService') 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) => { exports.getAllCategories = catchAsync(async (req, res, next) => {
const categories = await categoryService.getAllCategories() const categories = await categoryService.getAllCategories()