Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 647 Bytes

class-transformer.md

File metadata and controls

34 lines (26 loc) · 647 Bytes

class-transformer

Keywords: Objects-mapping, Serialization

Links

Glossary

  • Data Transfer Object (DTO)

Snippets

//
@Expose({ name: 'domain' })
@Transform(({ value }) => value.domain)
domain!: string

//
@Expose({ name: 'integrations' })
@Transform(
  ({ value }) =>
    value.reduce(
      (acc: Record<string, string>, { type, data }: PageIntegration) =>
        Object.assign(acc, { [type]: data }),
      {},
    ),
  { toClassOnly: true },
)
integrations!: Record<string, string>