# Getting started

Let's take the following source and destination types:

```typescript
interface CustomerDto {
    firstName: string;
    lastName: string;
}

interface Customer {
    firstName: string;
    lastName: string;
    fullName: string;
}
```

TypeScript static typings are not available at runtime. To introduce a runtime representation of mapping from `CustomerDto` to `Customer` a `MappingPair` token has to be created.

```typescript
import { MappingPair } from '@dynamic-mapper/mapper';

const CustomerDtoToCustomer = new MappingPair<CustomerDto, Customer>();
```

### Mapping configuration

Configuring strategies are described [here](https://dynamic-mapper.gitbook.io/dynamic-mapper/configuration).

```typescript
import { MapperConfiguration } from '@dynamic-mapper/mapper';

const configuration = new MapperConfiguration(cfg => {
    cfg.createAutoMap(CustomerDtoToCustomer, {
        fullName: opt => opt.mapFrom(src => `${src.firstName} ${src.lastName}`)
    });
});
```

### Mapping

```typescript
const mapper = configuration.createMapper();

const customer: CustomerDto = {
    firstName: 'John',
    lastName: 'Doe'
};

const dto = mapper.map(CustomerDtoToCustomer, customer);
console.log(dto);
// { firstName: 'John', lastName: 'Doe', fullName: 'John Doe' }
```
