All files / api/user/infrastructure user.mapper.ts

0% Statements 0/14
100% Branches 0/0
0% Functions 0/3
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                                 
import { IUserAggregate } from '@INTERFACE/user/domain';
import { UserAggregate } from '@USER/domain';
import { UserEntity } from './user.entity';
 
export const entity_to_aggregate =
  (profile: IUserAggregate.Profile) => (entity: UserEntity) => {
    const { created_at, updated_at, role, id } = entity;
    const { email, username } = profile;
    return UserAggregate.get({
      id,
      email,
      username,
      role,
      created_at,
      updated_at,
    });
  };
 
export const aggregate_to_entity = (state: IUserAggregate.State) => {
  const entity = new UserEntity();
  entity.id = state.id;
  entity.role = state.role;
  return entity;
};