Skip to content

Latest commit

 

History

History
92 lines (72 loc) · 2.97 KB

README.md

File metadata and controls

92 lines (72 loc) · 2.97 KB

haskell-ddd-order-taking

build

About

This repository is Haskell implementation of the "Domain Modeling Made Functional" book.
(in the book, sample codes are written in F#).

The "place order" workflow in the book is implemented.

Run application

start server

run stack run start to start an API server at localhost:3000.

send requests

you can send POST requests to /orders endpoint.
request body contains "unvalidated order", and response body contains "place order events."

via Postman

you can use Postman to send requests using out-of-the-box request templates.
import the request collection file (test-postman/collection.json) and the environment variables file (test-postman/variables.json) to Postman.

via curl

example request is the following.

curl --location --request POST 'http://localhost:3000/orders' \
--header 'Content-Type: application/json' \
--data-raw '{
    "orderId": "test-order-id",
    "customerInfo": {
        "firstName": "test-first-name",
        "lastName": "test-last-name",
        "emailAddress": "[email protected]"
    },
    "shippingAddress": {
        "addressLine1": "test shipping street 1",
        "addressLine2": "test shipping street 2",
        "addressLine3": "test shipping street 3",
        "addressLine4": "test shipping street 4",
        "city": "test shipping city",
        "zipCode": "12345"
    },
    "billingAddress": {
        "addressLine1": "test billing street",
        "addressLine2": "",
        "addressLine3": "",
        "addressLine4": "",
        "city": "test billing city",
        "zipCode": "54321"
    },
    "orderLines": [
        {
            "orderLineId": "test-order-line-id1",
            "productCode": "W1234",
            "quantity": 1
        },
        {
            "orderLineId": "test-order-line-id2",
            "productCode": "G123",
            "quantity": 1.25
        }
    ]
}'

Automated test using hspec and sensei

run stack test to run all tests.

run stack exec sensei test/Spec.hs to run all tests on any modifications to the codes.

References

I referred to the following repositories and websites during development.