The Restaurant Menu API provides access to various categories of menu items such as appetizers, entrees, sandwiches, and more. This API allows users to retrieve menu items filtered by category and optional criteria such as price range and description keywords.
The API is served under the base URL http://localhost:4000/api
Ensure that the server is running on this port or configure it accordingly.
To run the Restaurant Menu API locally, follow these steps:
-
clone the repo
git clone https://github.com/bat-kryptonyte/restaurants-node-boilerplate.git cd restaurants-node-boilerplate
-
install dependencies Ensure you have Node.js and npm installed. Then, run:
npm install
- start the server
npm run build
npm run start
- running the test suite
npm test
Retrieve menu items filtered by category with optional query parameters to filter further based on price and description.
- URL:
/api/:category
- Method:
GET
- URL Params:
- Required:
category=[string] - The category of menu items to retrieve.
- Optional:
minPrice=[string] - Minimum price of the menu items.
maxPrice=[string] - Maximum price of the menu items.
descriptionContains=[string] - A keyword to search in the item descriptions.
- Required:
- Success Response:
- Code:
200 OK
- Content:
An array of menu items.
- Code:
- Error Response:
- Code:
404 Not Found
- Content:
{ error : "Category not found" }
- Code:
name (string): The name of the menu item.
description (string): Description of the menu item.
price (number): Price of the menu item.
GET /api/entrees?minPrice=10&maxPrice=20&descriptionContains=pasta
[
{
"name": "Farfalle Pasta with Braised Pork in Tomato Cream",
"description": "capers butternut squash kale",
"price": 12.95
}
]
Retrieves all sandwiches of a specified type, filters them based on query parameters such as minPrice
, maxPrice
, and descriptionContains
, and returns the filtered list in JSON format.
- URL:
/api/sandwiches/:type
- Method:
GET
- URL Params:
- Required:
type=[enum] - The type of sandwiches(hot or cold) to retrieve.
- Optional:
minPrice=[string] - Minimum price of the menu items.
maxPrice=[string] - Maximum price of the menu items.
descriptionContains=[string] - A keyword to search in the item descriptions.
- Required:
- Success Response:
- Code:
200 OK
- Content:
An array of menu items.
- Code:
- Error Response:
- Code:
404 Not Found
- Content:
{ error : "Type not found" }
- Code:
The Restaurant Menu API also supports GraphQL queries. Below are the GraphQL queries that can be used to interact with the API.
The GraphQL endpoint is available at http://localhost:4000/graphql
Fetch all menu items from a specific category.
- Query:
query GetMenuItemsByCategory($category: String!) {
getMenuItemsByCategory(category: $category) {
name
description
price
}
}
Retrieve all menu items across all categories.
- Query:
query GetAllMenuItems {
getAllMenuItems {
name
description
price
}
}
Search for manu items that include a specific keyword in their description
- Query:
query CustomQuery($search: String!) {
customQuery(search: $search) {
name
description
price
}
}