From e6bdf4b6c7b3c5f44f500fa59ec92de62fde3fb3 Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:18:16 +0530 Subject: [PATCH 1/6] chore : resolved sonar cloud issues --- src/common/utils/transformer/date.transformer.ts | 2 +- src/modules/event/dto/update-event.dto.ts | 2 +- src/modules/event/event.service.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/utils/transformer/date.transformer.ts b/src/common/utils/transformer/date.transformer.ts index 5e0fd6f..7f6e801 100644 --- a/src/common/utils/transformer/date.transformer.ts +++ b/src/common/utils/transformer/date.transformer.ts @@ -6,7 +6,7 @@ import { ValueTransformer } from 'typeorm'; export class TimeZoneTransformer implements ValueTransformer { // private timeZone: string; - constructor(private configService: ConfigService) {} + constructor(private readonly configService: ConfigService) {} // To DB: Convert the date to UTC before saving to(entityValue: Date): Date { diff --git a/src/modules/event/dto/update-event.dto.ts b/src/modules/event/dto/update-event.dto.ts index 597af5c..6a6cb6f 100644 --- a/src/modules/event/dto/update-event.dto.ts +++ b/src/modules/event/dto/update-event.dto.ts @@ -68,7 +68,7 @@ export class UpdateEventDto { example: { url: 'https://example.com/meeting', id: '123-456-789', - password: 'xxxxxxx', + // password: 'xxxxxxx', // This will be hidden from API response docs }, }) @IsObject() diff --git a/src/modules/event/event.service.ts b/src/modules/event/event.service.ts index c62f547..4e48b29 100644 --- a/src/modules/event/event.service.ts +++ b/src/modules/event/event.service.ts @@ -43,8 +43,8 @@ import { compareArrays } from 'src/common/utils/functions.util'; import * as moment from 'moment-timezone'; @Injectable() export class EventService { - private eventCreationLimit: number; - private timezone: string; + private readonly eventCreationLimit: number; + private readonly timezone: string; constructor( @InjectRepository(Events) From bade2ce73c268d2a9ae9046299aaedefc64137a2 Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:50:32 +0530 Subject: [PATCH 2/6] feat : zoom link modified regx --- src/common/utils/validation.util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/utils/validation.util.ts b/src/common/utils/validation.util.ts index affbb03..ea382d5 100644 --- a/src/common/utils/validation.util.ts +++ b/src/common/utils/validation.util.ts @@ -6,7 +6,7 @@ import { function validateMeetingUrl(url, provider) { const providerPatterns = { - zoom: /^https:\/\/[\w-]*\.?zoom.us\/(j|my)\/[-\w?=]+$/, + zoom: /^https?:\/\/[\w-]*\.?zoom\.(com|us)\/(j|my)\/[-\w?=]+(?:\?.*)?$/, googlemeet: /^(https:\/\/)?meet\.google\.com\/[a-zA-Z0-9-]+$/, // microsoftteams: /^(https:\/\/)?teams\.microsoft\.com\/[a-zA-Z0-9?&=]+$/, // Add other supported providers as needed From 150a219dd3f7f4bf34f2db0591645bca492986ae Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:06:42 +0530 Subject: [PATCH 3/6] feat : googlemeet link modified regx --- src/common/utils/validation.util.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/utils/validation.util.ts b/src/common/utils/validation.util.ts index ea382d5..489499a 100644 --- a/src/common/utils/validation.util.ts +++ b/src/common/utils/validation.util.ts @@ -7,7 +7,8 @@ import { function validateMeetingUrl(url, provider) { const providerPatterns = { zoom: /^https?:\/\/[\w-]*\.?zoom\.(com|us)\/(j|my)\/[-\w?=]+(?:\?.*)?$/, - googlemeet: /^(https:\/\/)?meet\.google\.com\/[a-zA-Z0-9-]+$/, + googlemeet: + /^https?:\/\/meet\.(google\.com|[a-zA-Z0-9-]+\.com)\/[a-z]{3,}-[a-z]{3,}-[a-z]{3}(\?[\w=&-]*)?$/, // microsoftteams: /^(https:\/\/)?teams\.microsoft\.com\/[a-zA-Z0-9?&=]+$/, // Add other supported providers as needed }; From d1c1dcada2be3d151f1b20b45cb081bc7c6ca468 Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:12:18 +0530 Subject: [PATCH 4/6] chore : handled http exception --- src/common/filters/exception.filter.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/filters/exception.filter.ts b/src/common/filters/exception.filter.ts index 7a034c6..0d60817 100644 --- a/src/common/filters/exception.filter.ts +++ b/src/common/filters/exception.filter.ts @@ -26,7 +26,16 @@ export class AllExceptionsFilter implements ExceptionFilter { let errorMessage = exception?.message || ERROR_MESSAGES.INTERNAL_SERVER_ERROR; - if (exception instanceof QueryFailedError) { + if (exception instanceof HttpException) { + const statusCode = exception.getStatus(); + const errorResponse = APIResponse.error( + this.apiId, + (exception.getResponse() as any)?.message, + ERROR_MESSAGES.BAD_REQUEST, + statusCode.toString(), + ); + return response.status(status).json(errorResponse); + } else if (exception instanceof QueryFailedError) { const statusCode = HttpStatus.UNPROCESSABLE_ENTITY; const errorResponse = APIResponse.error( this.apiId, From 375a33dee86ab24970576f582aa52ea6b88d0358 Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:30:54 +0530 Subject: [PATCH 5/6] refactor: changed zoom regx --- src/common/utils/validation.util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/utils/validation.util.ts b/src/common/utils/validation.util.ts index 489499a..6e5d3af 100644 --- a/src/common/utils/validation.util.ts +++ b/src/common/utils/validation.util.ts @@ -6,7 +6,7 @@ import { function validateMeetingUrl(url, provider) { const providerPatterns = { - zoom: /^https?:\/\/[\w-]*\.?zoom\.(com|us)\/(j|my)\/[-\w?=]+(?:\?.*)?$/, + zoom: /^https?:\/\/[\w-]*\.?zoom\.(com|us)\/(j|my)\/[\w-]+(\?[\w=&-]*)?$/, googlemeet: /^https?:\/\/meet\.(google\.com|[a-zA-Z0-9-]+\.com)\/[a-z]{3,}-[a-z]{3,}-[a-z]{3}(\?[\w=&-]*)?$/, // microsoftteams: /^(https:\/\/)?teams\.microsoft\.com\/[a-zA-Z0-9?&=]+$/, From 3ee00318ee17afc99c1c8c00eeb6110461fe7b0f Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:32:42 +0530 Subject: [PATCH 6/6] chore : coderabbit suggestion --- src/common/filters/exception.filter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/filters/exception.filter.ts b/src/common/filters/exception.filter.ts index 0d60817..2003a17 100644 --- a/src/common/filters/exception.filter.ts +++ b/src/common/filters/exception.filter.ts @@ -34,7 +34,7 @@ export class AllExceptionsFilter implements ExceptionFilter { ERROR_MESSAGES.BAD_REQUEST, statusCode.toString(), ); - return response.status(status).json(errorResponse); + return response.status(statusCode).json(errorResponse); } else if (exception instanceof QueryFailedError) { const statusCode = HttpStatus.UNPROCESSABLE_ENTITY; const errorResponse = APIResponse.error(