Git Product home page Git Product logo

pizza's Introduction

PIZZAS

Project Guidelines

Your project should conform to the following set of guidelines:

Models

You need to create the following relationships:

  • A Restaurant has many Pizzas through RestaurantPizza
  • A Pizza has many Restaurants through RestaurantPizza
  • A RestaurantPizza belongs to a Restaurant and belongs to a Pizza

Start by creating the models and migrations for the following database tables:

domain-1.png

Add any code needed in the model files to establish the relationships. Then, run the migrations.

You are welcome to generate your own seed data to test the application.

Validations Add validations to the RestaurantPizza model:

  • must have a price between 1 and 30

Routes

Set up the following routes. Make sure to return JSON data in the format specified along with the appropriate HTTP verb.

GET /restaurants Return JSON data in the format below:

[ { "id": 1, "name": "Sottocasa NYC", "address": "298 Atlantic Ave, Brooklyn, NY 11201" }, { "id": 2, "name": "PizzArte", "address": "69 W 55th St, New York, NY 10019" } ]

GET /restaurants/:id If the Restaurant exists, return JSON data in the format below:

{ "id": 1, "name": "Sottocasa NYC", "address": "298 Atlantic Ave, Brooklyn, NY 11201", "pizzas": [ { "id": 1, "name": "Cheese", "ingredients": "Dough, Tomato Sauce, Cheese" }, { "id": 2, "name": "Pepperoni", "ingredients": "Dough, Tomato Sauce, Cheese, Pepperoni" } ] }

If the Restaurant does not exist, return the following JSON data, along with the appropriate HTTP status code:

{ "error": "Restaurant not found" }

DELETE /restaurants/:id

If the Restaurant exists, it should be removed from the database, along with any RestaurantPizzas that are associated with it (a RestaurantPizza belongs to a Restaurant, so you need to delete the RestaurantPizzas before the Restaurant can be deleted).

After deleting the Restaurant, return an empty response body, along with the appropriate HTTP status code.

If the Restaurant does not exist, return the following JSON data, along with the appropriate HTTP status code:

{ "error": "Restaurant not found" }

GET /pizzas Return JSON data in the format below:

[ { "id": 1, "name": "Cheese", "ingredients": "Dough, Tomato Sauce, Cheese" }, { "id": 2, "name": "Pepperoni", "ingredients": "Dough, Tomato Sauce, Cheese, Pepperoni" } ]

POST /restaurant_pizzas This route should create a new RestaurantPizza that is associated with an existing Pizza and Restaurant. It should accept an object with the following properties in the body of the request:

{ "price": 5, "pizza_id": 1, "restaurant_id": 3 }

If the RestaurantPizza is created successfully, send back a response with the data related to the Pizza:

{ "id": 1, "name": "Cheese", "ingredients": "Dough, Tomato Sauce, Cheese" }

If the RestaurantPizza is not created successfully, return the following JSON data, along with the appropriate HTTP status code:

{ "errors": ["validation errors"] }

Video Link: https://drive.google.com/file/d/1bOvMBQXpoPW5JSBnvEf5scPFsj-1NAaR/view

pizza's People

Contributors

rawllings avatar

Watchers

 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.