An attempt to translate Domain Modeling Made Functional code examples to typescript
I'm using the following fp libraries to drive my solution
- fp-ts: FP ADTs and abstractions
- newtype-ts: isomorphic
newtype
types - fp-ts-contrib:
do notation
- Ramda: handy helper functions (specially curried array
map
)
Payload
{
"orderId": "order1",
"customerInfo": {
"firstName": "mehdi",
"lastName": "zonjy",
"emailAddress": "[email protected]",
"vipStatus":"normal"
},
"shippingAddress": {
"addressLine1": "address 1",
"addressLine2": "",
"addressLine3":"",
"addressLine4": "",
"city": "some city",
"zipCode": "12365",
"state": "DC",
"country": "aah"
},
"billingAddress": {
"addressLine1": "address 1",
"addressLine2": "",
"addressLine3":"",
"addressLine4": "",
"city": "some city",
"zipCode": "44445",
"state": "DC",
"country": "aah"
},
"lines":[{
"orderLineId": "orderLine1",
"productCode": "W1232",
"quantity": 123
}],
"promotionCode": "normal"
}