📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
new route to delete a category
Yevhenii K822ed0fc8c3f
diff --git a/src/marketplace/categories/categories.controller.ts b/src/marketplace/categories/categories.controller.tsindex cab30a170..046fd882c 100644--- a/src/marketplace/categories/categories.controller.ts+++ b/src/marketplace/categories/categories.controller.ts@@ -2,6 +2,7 @@ import {Body,ConflictException,Controller,+ Delete,NotFoundException,Param,Patch,@@ -11,6 +12,7 @@ import { ApiTags } from '@nestjs/swagger'import { CategoriesService } from './categories.service'import { Category } from './category.entity'import { CreateCategory } from './dtos/create-category.dto'+import { DeleteCategoryParams } from './dtos/delete-category-params.dto'import { UpdateCategoryParams } from './dtos/update-category-params.dto'import { UpdateCategory } from './dtos/update-category.dto'import { ISaveCategory } from './interfaces/save-category.interface'@@ -50,4 +52,15 @@ export class CategoriesController {return body}++ @Delete(':categoryId')+ async deleteCategory(@Param() params: DeleteCategoryParams): Promise<void> {+ const category = await this.categoriesService.findById(params.categoryId)++ if (!category) {+ throw new NotFoundException('Category not found.')+ }++ await this.categoriesService.delete(category.id)+ }}diff --git a/src/marketplace/categories/categories.service.ts b/src/marketplace/categories/categories.service.tsindex 14041e582..5e282698b 100644--- a/src/marketplace/categories/categories.service.ts+++ b/src/marketplace/categories/categories.service.ts@@ -36,4 +36,8 @@ export class CategoriesService {async update(id: number, category: IUpdateCategory): Promise<void> {await this.categoryRepository.update({ id }, category)}++ async delete(id: number): Promise<void> {+ await this.categoryRepository.delete({ id })+ }}diff --git a/src/marketplace/categories/dtos/delete-category-params.dto.ts b/src/marketplace/categories/dtos/delete-category-params.dto.tsnew file mode 100644index 000000000..a00f4578e--- /dev/null+++ b/src/marketplace/categories/dtos/delete-category-params.dto.ts@@ -0,0 +1,3 @@+export class DeleteCategoryParams {+ readonly categoryId!: number+}