Skip to content

📈 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!

added route for deleting extension comment

Yevhenii Kulisidi0e73fc640f79
diff --git a/src/marketplace/comments/comments.controller.ts b/src/marketplace/comments/comments.controller.ts
index 24bd2d076..164c382c7 100644
--- a/src/marketplace/comments/comments.controller.ts
+++ b/src/marketplace/comments/comments.controller.ts
@@ -1,5 +1,6 @@
import {
Controller,
+ Delete,
Get,
NotFoundException,
Param,
@@ -7,6 +8,7 @@ import {
} from '@nestjs/common'
import { ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger'
import { CommentsService } from './comments.service'
+import { DeleteCommentParamDto } from './dtos/params/delete-comment.dto'
import { GetCommentParamDto } from './dtos/params/get-comment.dto'
import { GetCommentsQueryDto } from './dtos/queries/get-comments.dto'
import { Comment } from './entities/comment.entity'
@@ -50,4 +52,18 @@ export class CommentsController {
return comment
}
+
+ @Delete(':commentId')
+ @ApiParam({ name: 'commentId', required: true, type: String })
+ async deleteComment(@Param() params: DeleteCommentParamDto): Promise<void> {
+ const comment = await this.commentsService.findOne({
+ where: { id: params.commentId },
+ })
+
+ if (!comment) {
+ throw new NotFoundException('Comment not found.')
+ }
+
+ await this.commentsService.delete(params.commentId)
+ }
}
diff --git a/src/marketplace/comments/comments.service.ts b/src/marketplace/comments/comments.service.ts
index 16d9972ba..0e8715389 100644
--- a/src/marketplace/comments/comments.service.ts
+++ b/src/marketplace/comments/comments.service.ts
@@ -18,4 +18,8 @@ export class CommentsService {
async findOne(options: FindOneOptions<Comment>): Promise<Comment> {
return await this.commentsRepository.findOne({ ...options })
}
+
+ async delete(id: string): Promise<void> {
+ await this.commentsRepository.delete(id)
+ }
}
diff --git a/src/marketplace/comments/dtos/params/delete-comment.dto.ts b/src/marketplace/comments/dtos/params/delete-comment.dto.ts
new file mode 100644
index 000000000..aa60f5529
--- /dev/null
+++ b/src/marketplace/comments/dtos/params/delete-comment.dto.ts
@@ -0,0 +1,6 @@
+import { IsNumberString } from 'class-validator'
+
+export class DeleteCommentParamDto {
+ @IsNumberString()
+ commentId: string
+}