Skip to content

DonationsService & Domain DTOs (Part 1) #8

@thaninbew

Description

@thaninbew

Summary:

Add the canonical domain DTOs and small normalization helpers that define the service contract. These are plain TypeScript types/classes (no Nest decorators) used by the service and unit tests.

Files to create:

  • apps/backend/src/donations/dtos/create-donation.domain.ts
  • apps/backend/src/donations/dtos/donation-response.domain.ts
  • apps/backend/src/donations/dtos/public-donation.domain.ts
  • apps/backend/src/donations/dtos/index.ts (export barrel)

Acceptance criteria:

  • Domain DTOs declare all fields required by the service (id, names, email, amount, isAnonymous, message, donationType, recurringInterval, dedicationMessage, createdAt, updatedAt).
  • No framework decorators; plain types or classes only.
  • Include minimal normalization helpers (amount parser, recurring normalization). Unit tests cover normalization.

Fields (domain DTOs):

  • CreateDonationDto (input to service.create):

    • firstName: string
    • lastName: string
    • email: string
    • amount: number (stored as numeric(10,2))
    • isAnonymous: boolean (default false)
    • donationType: 'one_time' | 'recurring'
    • recurringInterval?: string | null (normalized form: 'monthly' | 'bimonthly' | 'quarterly' | 'annually' | 'weekly')
    • dedicationMessage?: string | null
    • showDedicationPublicly?: boolean (default false)
  • DonationResponseDto (returned by service):

    • id: number
    • all fields from CreateDonationDto as stored
    • createdAt: string (ISO)
    • updatedAt: string (ISO)
  • PublicDonationDto (public-safe view):

    • id: number
    • amount: number
    • donationType: 'one_time' | 'recurring'
    • dedicationMessage?: string | null (only when allowed by donor)
    • isAnonymous: boolean
    • donorName?: string | null (omit or anonymize if isAnonymous)
    • createdAt: string (ISO)

Notes:

  • These files are the source of truth for the service contract. Part 2 (service implementation) depends on Part 1.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions