# FE Core

### Adapters and Transformers
* **NON inherited entities**:
    * The **adapter** implements both _AdapterInterface_ and  _TransformerInterface_.
    * The _AdapterInterface_ will be used to adapt self data.
    * The _TransformerInterface_ will be used to adapt data from the parent **transformer** if exists _(when adapting mixed lists such as products list)_.
    
* **Inherited entities**:
    * The **adapter** implements only _AdapterInterface_ and its responsibility is using the proper
    injected adapter.
    * At the highest level we need only 1 **transformer** with the proper switch to call these adapters.

* **Use**
    * If the data we are trying to transform is from a basic entity (EventProduct, Stop, Perk, ...)
    we are using the **adapter** and either the **adapt** method or the **transform** method
    (preferring the transform one so we can avoid the **new** entity call).
    * If the data we are trying to transform is from a parent entity (Product with type="event") we
    are using a **factory** with the **EventProductAdapter** injected. Inside the factory we will
    use a switch to determine which **adapter** we must use and then we will call the adapt method
    since this **factory** accepts only _AdapterInterface_.

### Services
Every service will extend BaseEntityService since the logic is generic and reusable. Also we are typing the service
with the proper entity to let the system (and the programmer) know what entity is being returned or used every time.

### Clients
Every client will extend BaseEntityClient since the logic is generic and reusable. For clients we are only implementing
the abstract method **getBasepath()** to let the system know where the endpoint starts.

### Factories
The factories will be used to transform data from a mixed list or when the data comes from a parent
entity and a **type** attribute (for example when retrieving data of an event product but the data
is coming from a Products endpoint with the attribute type="product").



## Scripts
#### Start
* ```npm run start``` or ```npm start```: Installs everything and launches webpack in dev mode.
* ```npm run start:fresh```: Removes **node_modules** and **public** folder and then runs ```npm start```.
This is mainly used for when changing some dependencies.

#### Webpack
* ```npm run webpack:dev```: Launches webpack in dev mode - watch and dev build. Use this one for dev mode
when you don't need to install nor check dependencies.
* ```npm run webpack:prod```: Launches webpack in prod mode - production build.

#### Build
* ```npm run build```: Removes **node_modules** and **public** folder and then runs ```npm run webpack:prod``` for a fresh build production.

#### Tests
* ```npm test``` or ```npm run test```: Runs Jest testing.