First, build docker container and run:
docker-compose build
docker-compose up -d
Install composer packages
docker-compose run --rm app composer install
copy .env.example to .env file and generate app key
cp .env.example .env
docker-compose run --rm app php artisan key:generate
Run migration and seeders
docker-compose run --rm app php artisan migrate --seed
First, create sqlite database
touch database/database.sqlite
Run migration and seeders for testing
docker-compose run --rm app php artisan migrate --seed --env=testing
Run tests
docker-compose run --rm app php artisan test
API requests must include api. For example the root of the API is at /api.
Valid API request
curl -H "Accept: application/json" 'http://localhost/api/products'
You can use Postman collection for testing.
Route | HTTP Verb | Body | Header | Description |
---|---|---|---|---|
/auth | POST |
{'email':'foo@bar.com','password':'password'} | Get user token. |
Route | HTTP Verb | Body | Header | Description |
---|---|---|---|---|
/user | GET |
Empty | Authorization:Bearer token | Get current user data. |
/user/product | GET |
Empty | Authorization:Bearer token | Get user's orders. |
/user/product | POST |
{'sku' : 'traktor-pro-3'} | Authorization:Bearer token | Add new order to user. |
/user/product/:sku | DELETE |
Empty | Authorization:Bearer token | Delete user's order with sku. |
Route | HTTP Verb | Body | Header | Description |
---|---|---|---|---|
/products | GET |
Empty | Authorization:Bearer token | Get all products. |
If a user places an order for the same item multiple times and wants to cancel only one of these items, this is not possible using the current structure. My suggestion would be to create a unique key for each one of the orders and for each item in those orders, and carry out all communications through this key.