Skip to content

BW-Foodie-Fun2/Back-End

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Back-End Documentation

API Base Url:

https://foodiefunbw.herokuapp.com/

Design Details


Register New User


HTTP Method: [POST]
URL: /api/auth/register

Schema:

Name Type Required description
username string yes unique username
password string yes password
email string yes unique email
location string yes string

Example

{
	"username": "EthanHoover0",
	"password": "123",
	"email": "ethanhoovernamename@gmail.com",
	"location": "Las Vegas"
}

The returned object will be:

{
    "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkV0aGFuSG9vdmVyMCIsImlhdCI6MTU4MDc5MTkxOCwiZXhwIjoxNTgwODc4MzE4fQ.lw7pcQD_JXyhI4NOL1TjjMbUiggNs-ShFhWWfhk7xlU",
    "message": "Welcome EthanHoover0"
}

Login


HTTP Method: [POST]
URL: /api/auth/login

Schema:

Name Type Required description
username string yes unique username
password string yes password

Example

{
	"username": "EthanHoover0",
	"password": "123"
}

The returned object will be:

{
    "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkV0aGFuSG9vdmVyMCIsImlhdCI6MTU4MDc5MTkxOCwiZXhwIjoxNTgwODc4MzE4fQ.lw7pcQD_JXyhI4NOL1TjjMbUiggNs-ShFhWWfhk7xlU",
    "message": "Welcome back EthanHoover0!"
}

Submit Review


HTTP Method: [POST]
URL: /api/reviews

Must be validated user with token

Schema:

Name Type Required description
menu_item string yes name of item from menu
item_price integer yes price of item
item_rating integer yes number rating of item
restaurant_id integer yes the id given to a restaurant
item_review string yes review of item
item_image_url string yes picture of item in jpg form
date_visited date yes date of visitation

Example

{
	      "menu_item": "burrito",
          "item_price": 6.50,
          "item_rating": 4,
          "restaurant_id": 2,
          "item_review": "Yeah it was okay.",
          "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
          "date_visited": "2020-1-05"
}

The returned object:

{
    "id": 4,
    "menu_item": "burrito",
    "item_price": 6.5,
    "item_rating": 4,
    "item_review": "Yeah it was okay.",
    "restaurant_id": 2,
    "reviewed_by": "EthanHoover",
    "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
    "created_at": "2020-02-04 04:59:46",
    "updated_at": "2020-02-04 04:59:46",
    "date_visited": "2020-1-05"
}

Update a Review


HTTP Method: [PUT]
URL: /api/reviews/:id

Must be validated user with token

Schema:

Name Type Required description
menu_item string yes/no name of item from menu
item_price integer yes/no price of item
item_rating integer yes/no number rating of item
restaurant_id integer yes/no the id given to a restaurant
item_review string yes/no review of item
item_image_url string yes/no picture of item in jpg form
date_visited date yes/no date of visitation

Example

{
	"name": "Nice Sweet Potatoes"
}

The returned object will be the same as the updated fields above

{
    "name": "Nice Sweet Potatoes"
}

Retrieve All Reviews


HTTP Method: [GET]
URL: /api/reviews

The returned object will look like:

[
    {
        "id": 1,
        "menu_item": "Mushroom Burger",
        "item_price": 8,
        "item_rating": 5,
        "item_review": "Nice well cooked shroom burger!",
        "restaurant_id": 1,
        "reviewed_by": "ethan",
        "item_image_url": "https://www.simplyrecipes.com/wp-content/uploads/2011/06/grilled-beef-mushroom-burgers-verrtical-a-1800.jpg",
        "created_at": "2020-02-03 20:39:38",
        "updated_at": "2020-02-03 20:39:38",
        "date_visited": "2020-1-20"
    },
    {
        "id": 2,
        "menu_item": "Cheesy Bean Burrito",
        "item_price": 7,
        "item_rating": 3,
        "item_review": "Okay burrito, too cheesy.",
        "restaurant_id": 3,
        "reviewed_by": "kelly",
        "item_image_url": "https://images-gmi-pmc.edge-generalmills.com/074a3680-3adc-4aae-85f5-1e3a4f2caa34.jpg",
        "created_at": "2020-02-03 20:39:38",
        "updated_at": "2020-02-03 20:39:38",
        "date_visited": "2020-1-10"
    },
]

Delete a Review


HTTP Method: [DELETE]
URL: /api/reviews/:id Must be validated user with token

Schema:

Name Type Required description
id integer yes review id

Example

[url]/api/user/:id

returns:

nothing as of right now

Retrieve All Reviews


HTTP Method: [GET]
URL: /api/users/:username/reviews

The returned object will look like:

[
    {
        "id": 4,
        "menu_item": "burrito",
        "item_price": 6.5,
        "item_rating": 4,
        "item_review": "Yeah it was okay.",
        "restaurant_id": 2,
        "reviewed_by": "EthanHoover0",
        "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
        "created_at": "2020-02-04 18:21:54",
        "updated_at": "2020-02-04 18:21:54",
        "date_visited": "2020-1-05"
    },
    {
        "id": 5,
        "menu_item": "Super Amazing Salad",
        "item_price": 20.5,
        "item_rating": 5,
        "item_review": "Yeah it was amazing.",
        "restaurant_id": 1,
        "reviewed_by": "EthanHoover0",
        "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
        "created_at": "2020-02-04 18:25:37",
        "updated_at": "2020-02-04 18:25:37",
        "date_visited": null
    }
]

Submit a Restaurant


HTTP Method: [POST]
URL: /api/restaurants

Must be validated user with token

Schema:

Name Type Required description
name string yes name of restaurant
cuisine_id integer yes type of cusine
location string yes location of restaurant
hours_of_operation string yes hours of operation
img_url string yes picture of restaurant in jpg form
created_by string yes* this is automatically passed through body on the request

Example

{
	    "name": "Nicole's Cafe",
	    "cuisine_id": 1,
        "location": "San Diego, CA",
        "hours_of_operation": "9:00AM - 9:00PM",
        "img_url": "https://koreatownladirectory.com/wpcontent/uploads/2015/02/nicoles-cafe-koreatown-plaza.jpg"
}

The returned object:

{
    "id": 23,
    "name": "Nicole's Cafe",
    "cuisine_id": 1,
    "location": "San Diego, CA",
    "hours_of_operation": "9:00AM - 9:00PM",
    "img_url": "https://koreatownladirectory.com/wpcontent/uploads/2015/02/nicoles-cafe-koreatown-plaza.jpg",
    "created_by": "nicole",
    "created_at": "2020-02-05 00:46:48",
    "updated_at": "2020-02-05 00:46:48"
}

Update a Restaurant


HTTP Method: [PUT]
URL: /api/restaurants/:id

Must be validated user with token


Retrieve All Restaurants


HTTP Method: [GET]
URL: /api/restaurants

The returned object will look like:

[
 {
        "id": 1,
        "name": "Five Guys",
        "cuisine_name": "American",
        "location": "Las Vegas, NV",
        "hours_of_operation": "11:00AM - 9:00PM",
        "img_url": "https://www.rd.com/wp-content/uploads/2019/02/five-guys.jpg",
        "created_by": "ethan"
    },
    {
        "id": 2,
        "name": "Egg Works",
        "cuisine_name": "American",
        "location": "Las Vegas, NV",
        "hours_of_operation": "7:00AM - 1PM",
        "img_url": "https://media-cdn.tripadvisor.com/media/photo-s/08/1b/0a/26/egg-works.jpg",
        "created_by": "josh"
    }
]

Delete a Restaurant


HTTP Method: [DELETE]
URL: /api/restaurants/:id Must be validated user with token

Schema:

Name Type Required description
id integer yes restaurant id

Example

[url]/api/restaurants/1

returns:

nothing as of right now

Retrieve Reviews by Restaurant


HTTP Method: [GET]
URL: /api/:restaurant_id/reviews

The returned object will look like:

[
    {
        "id": 1,
        "menu_item": "Mushroom Burger",
        "item_price": 8,
        "item_rating": 5,
        "item_review": "Nice well cooked shroom burger!",
        "restaurant_id": 1,
        "reviewed_by": "ethan",
        "item_image_url": "https://www.simplyrecipes.com/wp-content/uploads/2011/06/grilled-beef-mushroom-burgers-verrtical-a-1800.jpg",
        "created_at": "2020-02-07 19:41:50",
        "updated_at": "2020-02-07 19:41:50",
        "date_visited": "2020-1-20"
    }
]

Retrieve All Reviews by a certain user


HTTP Method: [GET]
URL: /api/users/:username/reviews

The returned object will look like:

[
    {
        "id": 4,
        "menu_item": "burrito",
        "item_price": 6.5,
        "item_rating": 4,
        "item_review": "Yeah it was okay.",
        "restaurant_id": 2,
        "reviewed_by": "EthanHoover0",
        "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
        "created_at": "2020-02-04 18:21:54",
        "updated_at": "2020-02-04 18:21:54",
        "date_visited": "2020-1-05"
    },
    {
        "id": 5,
        "menu_item": "Super Amazing Salad",
        "item_price": 20.5,
        "item_rating": 5,
        "item_review": "Yeah it was amazing.",
        "restaurant_id": 1,
        "reviewed_by": "EthanHoover0",
        "item_image_url": "https://www.mrbreakfast.com/images/1077_spicy_cheesy_eggs.jpg",
        "created_at": "2020-02-04 18:25:37",
        "updated_at": "2020-02-04 18:25:37",
        "date_visited": null
    }
]

Retrieve All Restaurants created by a user


HTTP Method: [GET]
URL: /api/users/:username/restaurants

The returned object will look like:

[
    {
        "name": "Zaba00s0850080",
        "cuisine_name": "Mexican",
        "location": "Las Vegas, NV",
        "hours_of_operation": "11:00AM - 9PM",
        "img_url": "sfdsdf"
    },
    {
        "name": "Zaba00s0850080",
        "cuisine_name": "Mexican",
        "location": "Las Vegas, NV",
        "hours_of_operation": "11:00AM - 9PM",
        "img_url": "sfdsdf"
    }
]

HTTP Method: [get]

URL: /api/cuisines

returns all seeded cuisines

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors