ADD: SignedUrls for documents, mainImage and images

ADD: Bucket and Upload System
ADD: New errors
ADD: Virtuals for categories
ADD: Features system
ADD: File management system
This commit is contained in:
2025-01-04 22:06:43 +03:30
parent 9e342cbc57
commit 2d87cc4834
21 changed files with 2100 additions and 77 deletions
+53
View File
@@ -0,0 +1,53 @@
const Feature = require('./featureModel')
const AppError = require('../../globalErrorHandler/AppError')
const categoryService = require('../category/categoryService')
exports.getAllCategoryFeatures = async () => {
const groups = JSON.parse(JSON.stringify(await categoryService.getAllCategories()))
for (let group of groups) {
group.features = await Feature.find({ category: category._id })
}
return groups
}
module.exports.getFeatureByCategory = async (categoryId) => {
return Feature.find({category: categoryId}, null, null)
}
module.exports.getAllFeatures = async (query) => {
return Feature.find(query, null, null)
}
module.exports.createFeatures = async (data) => {
return Feature.create(data, null)
}
module.exports.getFeatures = async (featureId) => {
const group = await Feature.findById(featureId)
if (!group) {
throw new AppError('NoGroupFound', 404, {})
}
return group
}
module.exports.updateFeatures = async (featureId, data) => {
const group = await Feature.findOneAndUpdate({ _id: featureId }, data)
if (!group) {
throw new AppError('NoGroupFound', 404, {})
}
return group
}
module.exports.deleteFeatures = async (featureId) => {
const group = await Feature.findOneAndUpdate({ _id: featureId }, { isActive: false })
if (!group) {
throw new AppError('NoGroupFound', 404, {})
}
return null
}