From afb4506ac7d5bfe970c45ef0d8d80e0269dac4e0 Mon Sep 17 00:00:00 2001 From: rajdip-b Date: Thu, 22 Feb 2024 12:08:26 +0530 Subject: [PATCH] made modifications --- apps/api/src/secret/dto/create.secret/create.secret.ts | 3 ++- apps/api/src/secret/service/secret.service.ts | 10 ++++++---- .../variable/dto/create.variable/create.variable.ts | 3 ++- apps/api/src/variable/service/variable.service.ts | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/api/src/secret/dto/create.secret/create.secret.ts b/apps/api/src/secret/dto/create.secret/create.secret.ts index f0017591..3c8065a8 100644 --- a/apps/api/src/secret/dto/create.secret/create.secret.ts +++ b/apps/api/src/secret/dto/create.secret/create.secret.ts @@ -1,4 +1,4 @@ -import { IsNumber, IsOptional, IsString } from 'class-validator' +import { IsNumber, IsOptional, IsString, Length } from 'class-validator' export class CreateSecret { @IsString() @@ -9,6 +9,7 @@ export class CreateSecret { @IsString() @IsOptional() + @Length(0, 100) note: string @IsNumber() diff --git a/apps/api/src/secret/service/secret.service.ts b/apps/api/src/secret/service/secret.service.ts index 7fbafdcd..808ecf10 100644 --- a/apps/api/src/secret/service/secret.service.ts +++ b/apps/api/src/secret/service/secret.service.ts @@ -170,7 +170,7 @@ export class SecretService { }, data: { name: dto.name, - note: dto.note ?? secret.note, + note: dto.note, rotateAt: addHoursToDate(dto.rotateAfter), lastUpdatedById: user.id, versions: { @@ -188,9 +188,11 @@ export class SecretService { id: secretId }, data: { - note: dto.note ?? secret.note, - name: dto.name ?? secret.name, - rotateAt: dto.rotateAfter ?? secret.rotateAt, + note: dto.note, + name: dto.name, + rotateAt: dto.rotateAfter + ? addHoursToDate(dto.rotateAfter) + : undefined, lastUpdatedById: user.id } }) diff --git a/apps/api/src/variable/dto/create.variable/create.variable.ts b/apps/api/src/variable/dto/create.variable/create.variable.ts index 4c608332..07f49b4b 100644 --- a/apps/api/src/variable/dto/create.variable/create.variable.ts +++ b/apps/api/src/variable/dto/create.variable/create.variable.ts @@ -1,4 +1,4 @@ -import { IsNumber, IsOptional, IsString } from 'class-validator' +import { IsNumber, IsOptional, IsString, Length } from 'class-validator' export class CreateVariable { @IsString() @@ -9,6 +9,7 @@ export class CreateVariable { @IsString() @IsOptional() + @Length(0, 100) note: string @IsNumber() diff --git a/apps/api/src/variable/service/variable.service.ts b/apps/api/src/variable/service/variable.service.ts index 2e2835cd..d8511224 100644 --- a/apps/api/src/variable/service/variable.service.ts +++ b/apps/api/src/variable/service/variable.service.ts @@ -194,8 +194,8 @@ export class VariableService { id: variableId }, data: { - note: dto.note ?? variable.note, - name: dto.name ?? variable.name, + note: dto.note, + name: dto.name, lastUpdatedById: user.id } })