From 67b0e810f5edd53753eb39b3c6b1ce3a98a9c39a Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Sun, 29 Dec 2024 19:45:20 +0330 Subject: [PATCH] ADD: get all category handler --- components/category/categoryController.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/category/categoryController.js b/components/category/categoryController.js index e69de29..e468c03 100644 --- a/components/category/categoryController.js +++ b/components/category/categoryController.js @@ -0,0 +1,14 @@ +const catchAsync = require('../../globalErrorHandler/catchAsync') +const AppError = require('../../globalErrorHandler/AppError') +const Category = require('./categoryModel') +const categoryService = require('./categoryService') + +exports.getAllCategories = catchAsync(async (req, res, next) => { + const categories = await categoryService.getAllCategories() + + res.status(200).json({ + status: 'success', + results: categories.length, + data: categories, + }) +})