Skip to content

Commit

Permalink
refactor:org create API (#761)
Browse files Browse the repository at this point in the history
* refactore:added metadata fields in org

Signed-off-by: pallavicoder <[email protected]>

* refactor:dto change

Signed-off-by: pallavicoder <[email protected]>

---------

Signed-off-by: pallavicoder <[email protected]>
  • Loading branch information
pallavighule authored Jun 11, 2024
1 parent 5f82ac8 commit cf35d64
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 42 deletions.
106 changes: 64 additions & 42 deletions apps/api-gateway/src/organization/dtos/create-organization-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,68 @@ import { IsNotSQLInjection, trim } from '@credebl/common/cast.helper';

@ApiExtraModels()
export class CreateOrganizationDto {
@ApiProperty()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Organization name is required.' })
@MinLength(2, { message: 'Organization name must be at least 2 characters.' })
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' })
@IsString({ message: 'Organization name must be in string format.' })
@IsNotSQLInjection({ message: 'Organization name is required.' })
name: string;

@ApiProperty()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Organization name is required.' })
@MinLength(2, { message: 'Organization name must be at least 2 characters.' })
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' })
@IsString({ message: 'Organization name must be in string format.' })
@IsNotSQLInjection({ message: 'Organization name is required.' })
name: string;

@ApiPropertyOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Description is required.' })
@MinLength(2, { message: 'Description must be at least 2 characters.' })
@MaxLength(255, { message: 'Description must be at most 255 characters.' })
@IsString({ message: 'Description must be in string format.' })
description: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
website?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'notificationWebhook is required.' })
@IsString({ message: 'notificationWebhook must be in string format.' })
@IsUrl({
// eslint-disable-next-line camelcase
require_protocol: true, // require URL protocol (e.g., http:// or https://)
// eslint-disable-next-line camelcase
require_tld: true // require top-level domain (e.g., .com, .net)

})
notificationWebhook?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'logo must be in string format.' })
logo?: string = '';
}
@ApiPropertyOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Description is required.' })
@MinLength(2, { message: 'Description must be at least 2 characters.' })
@MaxLength(255, { message: 'Description must be at most 255 characters.' })
@IsString({ message: 'Description must be in string format.' })
description: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
website?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'notificationWebhook is required.' })
@IsString({ message: 'notificationWebhook must be in string format.' })
@IsUrl({
// eslint-disable-next-line camelcase
require_protocol: true, // require URL protocol (e.g., http:// or https://)
// eslint-disable-next-line camelcase
require_tld: true // require top-level domain (e.g., .com, .net)
})
notificationWebhook?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'logo must be in string format.' })
logo?: string = '';

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'registrationNumber must be in string format.' })
registrationNumber?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'country must be in string format.' })
country?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'state must be in string format.' })
state?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'city must be in string format.' })
city?: string;
}
4 changes: 4 additions & 0 deletions apps/organization/dtos/create-organization.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class CreateOrganizationDto {
updatedBy?:string;
lastChangedBy?:string;
notificationWebhook?: string;
registrationNumber?:string;
country?:string;
city?:string;
state?:string;
}

export class CreateUserRoleOrgDto {
Expand Down
4 changes: 4 additions & 0 deletions apps/organization/repositories/organization.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class OrganizationRepository {
website: createOrgDto.website,
orgSlug: createOrgDto.orgSlug,
publicProfile: false,
registrationNumber:createOrgDto.registrationNumber,
country:createOrgDto.country,
city:createOrgDto.city,
state:createOrgDto.state,
createdBy: createOrgDto.createdBy,
lastChangedBy: createOrgDto.lastChangedBy
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "organisation" ADD COLUMN "city" VARCHAR(100),
ADD COLUMN "country" VARCHAR(100),
ADD COLUMN "registrationNumber" VARCHAR(100),
ADD COLUMN "state" VARCHAR(100);
4 changes: 4 additions & 0 deletions libs/prisma-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ model organisation {
idpId String? @db.VarChar(500)
clientId String? @db.VarChar(500)
clientSecret String? @db.VarChar(500)
registrationNumber String? @db.VarChar(100)
country String? @db.VarChar(100)
city String? @db.VarChar(100)
state String? @db.VarChar(100)
connections connections[]
credentials credentials[]
org_agents org_agents[]
Expand Down

0 comments on commit cf35d64

Please sign in to comment.