import { Mapper } from '@mobicoop/ddd-library'; import { Injectable } from '@nestjs/common'; import { RouteEntity } from './core/domain/route.entity'; import { RouteResponseDto } from './interface/dtos/route.response.dto'; /** * Mapper constructs objects that are used in different layers: * Record is an object that is stored in a database, * Entity is an object that is used in application domain layer, * and a ResponseDTO is an object returned to a user (usually as json). */ @Injectable() export class RouteMapper implements Mapper { toPersistence = (): undefined => { return undefined; }; // eslint-disable-next-line @typescript-eslint/no-unused-vars toDomain = (): undefined => { return undefined; }; // eslint-disable-next-line @typescript-eslint/no-unused-vars toResponse = (entity: RouteEntity): RouteResponseDto => { const response = new RouteResponseDto(); response.driverDistance = entity.getProps().driverDistance; response.driverDuration = entity.getProps().driverDuration; response.passengerDistance = entity.getProps().passengerDistance; response.passengerDuration = entity.getProps().passengerDuration; response.fwdAzimuth = entity.getProps().fwdAzimuth; response.backAzimuth = entity.getProps().backAzimuth; response.distanceAzimuth = entity.getProps().distanceAzimuth; response.points = entity.getProps().points; return response; }; }