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:
- 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())
- Update
loginUser.ts and registerUser.ts to use UserMapper.toResponseDTO()
- Update
loginUser.ts and auth.middleware.ts to use UserMapper.toDomain() instead of User.fromPersistence()
- 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)
Type: Refactoring | Priority: Medium | Depends on: REFACTOR-001
Description:
After removing DB and DTO methods from
Userentity, 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:
application/mappers/user.mapper.tswith:toResponseDTO(snapshot: UserSnapshot): UserResponseDTOtoDomain(row: UserDbRow): User(replacesUser.fromPersistence())toDBRow(snapshot: UserSnapshot): UserDbInsert(replacesuser.toPersistence())loginUser.tsandregisterUser.tsto useUserMapper.toResponseDTO()loginUser.tsandauth.middleware.tsto useUserMapper.toDomain()instead ofUser.fromPersistence()UserMapperindi/container.tsAcceptance Criteria:
user.toPersistence(),user.toResponseDTO(), orUser.fromPersistence()UserMappercovers all three transformation directionspnpm --filter backend ts-check)