GithubHelp home page GithubHelp logo

recipe_site's Introduction

Recipe_site

Back end for Recipe site. This is a Django-PostgreSQL project.

Recipe site development and testing

Abstract

This page describes how to quickly get the set of services comprising the backend up and running for development and testing.

Preconditions

Install latest Docker and Docker Compose. Currently tested platforms

  • Docker 17.04.0+
  • Docker Compose 1.10.0+
  • Ubuntu (16.04+) and MAC OS X 10.11+

If you are using a Linux machine then make sure to add your computer user to the docker group.

Checkout the Github repo

git clone https://github.com/jbernal0019/Recipe_site.git

Instantiate Recipe site

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.

Playing with the REST API

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 (hrefelements) 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.

A simple unauthenticated GET request:

Using curl:

curl http://localhost:8080/api/v1/

Using HTTPie REST API client:

http http://localhost:8080/api/v1/

Create a new user to be able to make authenticated requests:

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"}]}}' 'http://localhost:8080/api/v1/users/'

Using HTTPie REST API client:

http POST http://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

A simple POST request to create a new recipe:

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"}]}}' 'http://localhost:8080/api/v1/'

Using HTTPie REST API client:

http -a user:user1234 POST http://localhost:8080/api/v1/ template:='{"data":[{"name":"name","value":"recipe1"}]}' Content-Type:application/vnd.collection+json Accept:Application/vnd.collection+json

A simple PUT request to update an existing recipe:

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"}]}}' 'http://localhost:8080/api/v1/1/'

Using HTTPie REST API client:

http -a user:user1234 PUT http://localhost:8080/api/v1/1/ template:='{"data":[{"name":"name","value":"New name"}]}' Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json

A simple POST request to add a new ingredient to an existing recipe:

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"}]}}' 'http://localhost:8080/api/v1/1/ingredients/'

Using HTTPie REST API client:

http -a user:user1234 POST http://localhost:8080/api/v1/1/ingredients/ template:='{"data":[{"name":"text","value":"Ingredient1"}]}' Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json

Backend database design.

Available here.

Destroy Recipe site

Stop and remove Recipe site services by running the destroy bash script from the repository source directory:

./docker-destroy.sh

recipe_site's People

Contributors

jbernal0019 avatar

Watchers

 avatar  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.