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:
@@ -0,0 +1,70 @@
|
||||
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
||||
const AppError = require('../../globalErrorHandler/AppError')
|
||||
const featureService = require('./featureService')
|
||||
|
||||
exports.getAllCategoryFeatures = catchAsync(async (req, res, next) => {
|
||||
const features = await featureService.getAllCategoryFeatures()
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: features.length,
|
||||
data: features,
|
||||
})
|
||||
})
|
||||
|
||||
exports.getFeatureByCategory = catchAsync(async (req, res, next) => {
|
||||
const features = await featureService.getFeatureByCategory(req.params.categoryId)
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: features.length,
|
||||
data: features,
|
||||
})
|
||||
})
|
||||
|
||||
exports.getAllFeatures = catchAsync(async (req, res, next) => {
|
||||
const features = await featureService.getAllFeatures()
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: features.length,
|
||||
data: features,
|
||||
})
|
||||
})
|
||||
|
||||
exports.createFeature = catchAsync(async (req, res, next) => {
|
||||
const feature = await featureService.createFeatures(req.body)
|
||||
|
||||
res.status(201).json({
|
||||
status: 'success',
|
||||
data: feature,
|
||||
})
|
||||
})
|
||||
|
||||
exports.getFeature = catchAsync(async (req, res, next) => {
|
||||
const feature = await featureService.getFeatures(req.params.id)
|
||||
|
||||
if (!feature) {
|
||||
throw AppError('NoGroupFound', 404, {})
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
data: feature,
|
||||
})
|
||||
})
|
||||
|
||||
exports.updateFeature = catchAsync(async (req, res, next) => {
|
||||
const updatedFeature = await featureService.updateFeatures(req.params.groupId, req.body)
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
data: updatedFeature,
|
||||
})
|
||||
})
|
||||
|
||||
exports.deleteFeature = catchAsync(async (req, res, next) => {
|
||||
await featureService.deleteFeatures(req.params.groupId)
|
||||
|
||||
res.status(204).json({
|
||||
status: 'success',
|
||||
data: null,
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user