ADD: get one category logic

This commit is contained in:
MohammadHMazarei
2024-12-29 19:56:07 +03:30
parent f1c7e378a7
commit 91a3c7b3b8
+10
View File
@@ -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
}