Skip to content

Create UserMapper in Application Layer #175

@gorushkin

Description

@gorushkin

Type: Refactoring | Priority: Medium | Depends on: REFACTOR-001

Description:

After removing DB and DTO methods from User entity, the transformation logic must live in an application-layer mapper (application/mappers/user.mapper.ts). Currently this logic is scattered across use cases and middleware.

Tasks:

  1. Create application/mappers/user.mapper.ts with:
    • toResponseDTO(snapshot: UserSnapshot): UserResponseDTO
    • toDomain(row: UserDbRow): User (replaces User.fromPersistence())
    • toDBRow(snapshot: UserSnapshot): UserDbInsert (replaces user.toPersistence())
  2. Update loginUser.ts and registerUser.ts to use UserMapper.toResponseDTO()
  3. Update loginUser.ts and auth.middleware.ts to use UserMapper.toDomain() instead of User.fromPersistence()
  4. Register UserMapper in di/container.ts

Acceptance Criteria:

  • No use case or middleware calls user.toPersistence(), user.toResponseDTO(), or User.fromPersistence()
  • UserMapper covers all three transformation directions
  • TypeScript check passes (pnpm --filter backend ts-check)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions