because I got bored of customising my CV for every job
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(organizations): remove non-null assertions and add fromDomain method

- Remove non-null assertion operators (!) from Organization entity
- Add proper constructor with explicit parameter validation
- Add static fromDomain method for consistent domain-to-GraphQL mapping
- Improve type safety and follow project conventions

+27 -7
+27 -7
apps/server/src/modules/organization/organization.entity.ts
··· 3 3 @ObjectType() 4 4 export class Organization { 5 5 @Field(() => String) 6 - id!: string; 6 + id: string; 7 7 8 8 @Field(() => String) 9 - name!: string; 9 + name: string; 10 10 11 11 @Field(() => String, { nullable: true }) 12 - description?: string | null; 12 + description: string | null; 13 13 14 14 @Field(() => Date) 15 - createdAt!: Date; 15 + createdAt: Date; 16 16 17 17 @Field(() => Date) 18 - updatedAt!: Date; 18 + updatedAt: Date; 19 19 20 - constructor(partial: Partial<Organization>) { 21 - Object.assign(this, partial); 20 + constructor(data: { 21 + id: string; 22 + name: string; 23 + description?: string | null; 24 + createdAt: Date; 25 + updatedAt: Date; 26 + }) { 27 + this.id = data.id; 28 + this.name = data.name; 29 + this.description = data.description ?? null; 30 + this.createdAt = data.createdAt; 31 + this.updatedAt = data.updatedAt; 32 + } 33 + 34 + static fromDomain(domainOrg: { id: string; name: string; description?: string | null; createdAt: Date; updatedAt: Date }): Organization { 35 + return new Organization({ 36 + id: domainOrg.id, 37 + name: domainOrg.name, 38 + description: domainOrg.description ?? null, 39 + createdAt: domainOrg.createdAt, 40 + updatedAt: domainOrg.updatedAt, 41 + }); 22 42 } 23 43 }