Git Product home page Git Product logo

mytheresa-cart-test's Introduction

MyTheresa Cart Test

I have developed the test following DDD and hexagonal architecture principles. The Application only uses InMemory repositories with prefilled data, so the data is not persisted through requests, but a different implementation can be developed and added with minimal changes to the existing code.

To have the development environment set up with docker:

cd docker
docker-compose up -d
docker-compose exec php composer install

Aftwerwards the test suite can be run using this command

docker-compose exec php php bin/phpunit

The application listens on port 80 by default. It can be changed in docker/docker-compose.yml.

To add a product to the current user's cart: PUT /cart/product/add

To retrieve the products in the current user's cart: GET /cart/product

In order to be able to retrieve the current user the Authorization HTTP header has to contain a bearer token. There is an accessible user with the "randomgeneratedtoken" token so it is easier to play with the API.

Example cURL calls would be:

curl -X GET \
  http://localhost/cart/product \
  -H 'Authorization: Bearer: randomgeneratedtoken' \
  -H 'Content-Type: application/json'
curl -X PUT \
  http://localhost/cart/product/add \
  -H 'Authorization: Bearer: randomgeneratedtoken' \
  -H 'Content-Type: application/json' \
  -H 'content-length: 19' \
  -d '{
    "productId": 1
}'

At first I developed a session based authentication but I scraped it because being a REST API using session based authentication made no sense. So I developed a simple token based authentication.

The docker images I developed are focused on development and for the testers. Another docker deployment images should be created for the deployment of this app.

mytheresa-cart-test's People

Contributors

davidonium avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.