From 91a3c7b3b8a612eed8be06df8d88663808781eff Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Sun, 29 Dec 2024 19:56:07 +0330 Subject: [PATCH] ADD: get one category logic --- components/category/categoryService.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/category/categoryService.js b/components/category/categoryService.js index dc773f4..fd37141 100644 --- a/components/category/categoryService.js +++ b/components/category/categoryService.js @@ -9,3 +9,13 @@ module.exports.createCategory = async (data) => { const category = Category.create(data, null) return category } + +module.exports.getCategory = async (categoryId) => { + const category = await Category.findById(categoryId) + + if (!category) { + throw new AppError('NoCategoryFound', 404, {}) + } + + return category +}