From fff2abf0a1585fb48ce1d1609b471b45d4acd9a6 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sun, 29 Dec 2024 19:34:43 +0100 Subject: [PATCH] chore : remove class-transformer --- dto/userresponse.dto.ts | 7 ++----- dto/wordresponse.dto.ts | 16 +++++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/dto/userresponse.dto.ts b/dto/userresponse.dto.ts index 5825d8b..53bf811 100644 --- a/dto/userresponse.dto.ts +++ b/dto/userresponse.dto.ts @@ -1,16 +1,13 @@ -import { Expose } from 'class-transformer'; + export class UserResponseDTO { constructor(partial: Partial) { Object.assign(this, partial); - this.id = partial.id; + } - @Expose() id: string; - @Expose() username: string; - @Expose() avatar: string; } diff --git a/dto/wordresponse.dto.ts b/dto/wordresponse.dto.ts index 2d84c37..27bd5f1 100644 --- a/dto/wordresponse.dto.ts +++ b/dto/wordresponse.dto.ts @@ -1,18 +1,20 @@ -import { Expose } from 'class-transformer'; - export class WordResponseDTO { constructor(partial: Partial) { - Object.assign(this, partial); + if (partial.id) this.id = partial.id + if (partial.value) this.value = partial.value + if (partial.ownerId) this.ownerId = partial.ownerId + if (partial.enabled) this.enabled = partial.enabled } - @Expose() + id: number; - @Expose() value: string; - @Expose() ownerId: string; - @Expose() enabled: boolean; + + toJSON() { + return { ...this } // here I make a POJO's copy of the class instance + } }