Profiles

You can organize your mapping with profiles. Simply extend Profile and defined your configuration inside the constructor. Custom profiles need to be registered to the mapper configuration.

import { Profile, MappingProfile } from '@dynamic-mapper/mapper';

class CustomerProfile extends Profile {
    static readonly DtoToDomain = new MappingProfile<CustomerDto, Customer>();

    constructor() {
        this.createMap(CustomerProfile.DtoToDomain, {
            fullName: opt => opt.ignore()
        });
    }
}

Later register profiles to the mapper configuration.

const config = new MapperConfiguration(cfg => {
    cfg.addProfile(new CustomerProfile());
});

Last updated