git clone https://github.com/nikhilesh2/Restaurant-API.git
cd Restaurant-API
npm install
(OPTIONAL) Replace access key id and secret key id
navigate to config.json
in the root directory
replace "accessKeyId"
and "secretAccessKey"
with your own.
Access keys can be found under IAM users in the AWS console
Get and run DynamoDBLocal
Download here
Navigate to the directory where it is located and run it with the following command:
java -jar dynamodb_local_latest/DynamoDBLocal.jar
NOTE: it should be running on port 8000
Create and populate the tables with the following commands:
npm run build-tables
Here are some additional commands that you may find helpful:
npm run delete-tables
- deletes all tables
npm run create-tables
- creates the necessary tables
npm run populate-tables
- populates tables with sample data
Just run npm run start
to try out the API
NOTE: Before trying out the API, it would be a good idea to run the unit tests to ensure everything is running smoothly with the following command:
npm run tests
Resource
GET
POST
DELETE
/restaurants
Get List of Restaurants
Create new Restaurant
Delete all Restaurants
/restaurants/:id
Get a Restaurant
Not allowed (405)
Delete a Restaurant
/restaurants/search
Search for restaurant(s)
Not allowed (405)
Not allowed (405)
/restaurants/:id/menus
Get all menus for a restaurant
Not allowed (405)
Delete all menus for a restaurant
(TODO) /restaurants/:id/reviews
Get all reviews for a restaurant
Create a new review for a restaurant
Delete all reviews for a restaurant
Name
Type
Required
Description
name
string
Required
The name of the restaurant
menu_ids
array
Optional
The menu ids for the restaurant
address
string
Required
The street address of the Restaurant
city
string
Required
The city the Restaurant is located in
zip_code
string
Required
The zip code of the Restaurant
country
string
Required
The country the Restaurant is located in
phone number
string
Required
The phone number of the Restaurant
email
string
Required
The email of the Restaurant
hours
object
Required
The hours in 24-hour time and days the restaurant is open. Restaurants will be considered closed during a specific day of the week if not provided. Below is an example of how to construct the object
image_url
string
Optional
An image of the Restaurant
"hours": {
"Monday": [
{
"hours_open_start": "10:00",
"hours_open_end": "13:00",
},
{
"hours_open_start": "16:00",
"hours_open_end": "17:00",
}
],
"Wednesday": [
{
"hours_open_start": "10:00",
"hours_open_end": "13:00",
}
],
...
}
Name
Type
Required
Description
id
string
Required
The id of the restaurant
Name
Type
Required
Description
id
string
Required
The id of the restaurant
Name
Type
Required
Description
name
string
Optional
The name of the restaurant
address
string
Optional
The street address of the Restaurant
city
string
Optional
The city the Restaurant is located in
zip_code
string
Optional
The zip code of the Restaurant
country
string
Optional
The country the Restaurant is located in
phone number
string
Optional
The phone number of the Restaurant
email
string
Optional
The email of the Restaurant
image_url
string
Optional
An image of the Restaurant
/restaurants/:id/menus
Name
Type
Required
Description
id
string
Required
The id of the restaurant
Name
Type
Required
Description
id
string
Required
The id of the restaurant
Menus
Resource
GET
POST
DELETE
/menus
Get all menus
Create new menu
Delete all menus
/menus/:id
Get a menu
Not allowed (405)
Delete a menu
menus/:id/menu-items
Get all menu items for a specific menu
Not allowed (405)
Delete all menu items for a specific menu
/menus
/menus/:id
Name
Type
Required
Description
id
string
Required
The id of the menu
Name
Type
Required
Description
id
string
Required
The id of the menu
/menus/:id/menu-items
Name
Type
Required
Description
id
string
Required
The id of the menu
Name
Type
Required
Description
id
string
Required
The id of the menu
Menu Items
Resource
GET
POST
DELETE
/menu-items
Get all menu items
Create new menu item
Delete all menu items
/menus/:id
Get a specific menu item
Not allowed (405)
Delete a specific menu item
menus/:id/menu-items
Get all menu items for a menu
Not allowed (405)
Delete all menu items from a menu
(TODO) menus/:id/reviews
Get all reviews for menu item
Create a new review for a specific menu item
Delete all reviews for menu item
/menu-items
Name
Type
Required
Description
menu_id
string
Required
The id of the menu that the menu item will be added to
name
string
Required
The name of the menu item
price
number
Required
The price of the menu item
section
string
Required
The section of the menu that the menu item is listed under. If the section doesn't already exist in menu, a new one will be created
description
string
Required
A description of the menu item
isVegan
boolean
Required
Whether or not the menu item is vegan
isVegetarian
boolean
Required
Whether or not the menu item is vegetarian
spicy
number
Required
A number ranging from 1 to 10 of how spicy the food is
allergies
array
Required
List of all potential allergens
/menu-items/:id
Name
Type
Required
Description
id
string
Required
The id of the menu item
Name
Type
Required
Description
id
string
Required
The id of the menu item
I have created a handful of unit tests for each of the endpoints. Make sure no other processes are running on the same port.
Type in the following command to run the unit tests
npm run tests
Due to time constraints there were a few things I didn't get to implement that I have outlined below.
Add reviews endpoint to restaurants and menu-items
Add more exhaustive testing to all of the endpoints and "other" methods
Add More extensive verifiers
Optimize database using best dynamoDB practices
Replace UUID with custom integer id generator to speed up queries
Add response body for each method in every endpoint to README