Skip to content

Commit

Permalink
fix: improve by coderabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
GloireMutaliko21 committed Nov 27, 2024
1 parent e95a214 commit c1385c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/subscription/subscription.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class SubscriptionController extends CrudController<Subscription> {
description: 'Record not found'
})
@Get(':id')
@UseValidationPipe()
async findById(
@Param('id', UUIDValidationPipe) id: ID,
@Query() params: OptionParams<Subscription>
Expand All @@ -63,7 +64,7 @@ export class SubscriptionController extends CrudController<Subscription> {
status: HttpStatus.BAD_REQUEST,
description: 'Invalid input, The response body may contain clues as to what went wrong'
})
@HttpCode(HttpStatus.ACCEPTED)
@HttpCode(HttpStatus.CREATED)
@Post()
@UseValidationPipe({ whitelist: true })
async create(@Body() entity: CreateSubscriptionDTO): Promise<ISubscription> {
Expand All @@ -81,6 +82,7 @@ export class SubscriptionController extends CrudController<Subscription> {
})
@HttpCode(HttpStatus.ACCEPTED)
@Delete('/:id')
@UseValidationPipe({ whitelist: true })
async delete(
@Param('id', UUIDValidationPipe) id: ID,
@Query() options: SubscriptionFindInputDTO
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/subscription/subscription.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export class SubscriptionService extends TenantAwareCrudService<Subscription> {
*/
async unsubscribe(id: ID, options?: ISubscriptionFindInput): Promise<DeleteResult> {
try {
const { entity, entityId } = options;
const { entity, entityId } = options || {};
const userId = RequestContext.currentUserId();
return await super.delete({ id, userId, entity, entityId });
} catch (error) {
throw new BadRequestException(error);
throw new BadRequestException('Failed to unsubscribe from entity', error);
}
}
}

0 comments on commit c1385c2

Please sign in to comment.