Back end for Recipe site. This is a Django-PostgreSQL project.
This page describes how to quickly get the set of services comprising the backend up and running for development and testing.
Docker 17.04.0+
Docker Compose 1.10.0+
Ubuntu (16.04+) and MAC OS X 10.11+
git clone https://github.com/jbernal0019/Recipe_site.git
Start Recipe site from the repository source directory by running the make bash script:
./docker-make.sh
All the steps performed by the above script are properly documented in the script itself.
After running this script all the automated tests should have successfully run and a Django development server should be running in interactive mode in this terminal.
This API uses the standard Collection+JSON hypermedia type to exchange resource representations with clients.
All the functionality provided by the API can be discovered by clients by doing GET
requests to links (href
elements) presented by the hypermedia documents returned by the web server, starting with the API’s “home page”.
As such the amount of required human-readable documentation is greatly minimized.
The only non-standard property that I have added to the hypermedia document format is total
which gives the total number of items across all API pages.
The API’s “home page” relative url is: /api/v1/ which serves a list of recipes.
Using curl:
curl https://localhost:8080/api/v1/
Using HTTPie REST API client:
http https://localhost:8080/api/v1/
Using curl:
curl -XPOST -H 'Content-Type: application/vnd.collection+json' -H 'Accept: application/vnd.collection+json' -d '{"template":{"data":[{"name":"username","value":"user"}, {"name":"email","value":"[email protected]"}, {"name":"password","value":"user1234"}]}}' 'https://localhost:8080/api/v1/users/'
Using HTTPie REST API client:
http POST https://localhost:8080/api/v1/users/ template:='{"data":[{"name":"username","value":"user"}, {"name":"email","value":"[email protected]"}, {"name":"password","value":"user1234"}]}' Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json
Using curl:
curl -u user:user1234 -XPOST -H 'Content-Type: application/vnd.collection+json' -H 'Accept: application/vnd.collection+json' -d '{"template":{"data":[{"name":"name","value":"recipe1"}]}}' 'https://localhost:8080/api/v1/'
Using HTTPie REST API client:
http -a user:user1234 POST https://localhost:8080/api/v1/ template:='{"data":[{"name":"name","value":"recipe1"}]}' Content-Type:application/vnd.collection+json Accept:Application/vnd.collection+json
Using curl:
curl -u user:user1234 -X PUT -H 'Content-Type: application/vnd.collection+json' -H 'Accept: application/vnd.collection+json' -d '{"template":{"data":[{"name":"name","value":"New name"}]}}' 'https://localhost:8080/api/v1/1/'
Using HTTPie REST API client:
http -a user:user1234 PUT https://localhost:8080/api/v1/1/ template:='{"data":[{"name":"name","value":"New name"}]}' Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json
Using curl:
curl -u user:user1234 -XPOST -H 'Content-Type: application/vnd.collection+json' -H 'Accept: application/vnd.collection+json' -d '{"template":{"data":[{"name":"text","value":"Ingredient1"}]}}' 'https://localhost:8080/api/v1/1/ingredients/'
Using HTTPie REST API client:
http -a user:user1234 POST https://localhost:8080/api/v1/1/ingredients/ template:='{"data":[{"name":"text","value":"Ingredient1"}]}' Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json
Available here.
Stop and remove Recipe site services by running the destroy bash script from the repository source directory:
./docker-destroy.sh