nestjs-blog
nestjs-blog copied to clipboard
no 'slug' param at /:slug/comments
no 'slug' information to comment service
@Post('/:slug/comments') and @Delete('/:slug/comments/:id')
@ApiBearerAuth()
@ApiCreatedResponse({ description: 'Create new comment' })
@ApiUnauthorizedResponse()
@ApiBody({ type: CreateCommentBody })
@Post('/:slug/comments')
async createComment(
@User() user: UserEntity,
@Body('comment', ValidationPipe) data: CreateCommentDTO,
): Promise<ResponseObject<'comment', CommentResponse>> {
const comment = await this.commentService.createComment(user, data);
return { comment };
}
@ApiBearerAuth()
@ApiOkResponse({ description: 'Delete comment' })
@ApiUnauthorizedResponse()
@Delete('/:slug/comments/:id')
async deleteComment(
@User() user: UserEntity,
@Param('id') id: number,
): Promise<ResponseObject<'comment', CommentResponse>> {
const comment = await this.commentService.deleteComment(user, id);
return { comment };
}