RESTful API to discover and explore a universe of recipes.
To run this project, you will need to add the following environment variables to your .env file
DB_URL
JWT_SECRET1
Clone the project
git clone https://github.com/JaviGarc1a/DiShared.gitGo to the project directory
cd DiSharedInstall dependencies
npm installPopulate database
npm run populateStart the server
npm startThis project runs on http://localhost:3000. After starting the server, you can access our Swagger documentation at http://localhost:3000/api-doc
POST /auth/login
Request body
| Parameter | Type | Description |
|---|---|---|
username |
string |
Required. Your username |
password |
string |
Required. Your password |
GET /users
POST /users
Request body
| Parameter | Type | Description |
|---|---|---|
username |
string |
Required. Your username |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
GET /users/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. User ID |
PUT /users/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. User ID |
Request body
| Parameter | Type | Description |
|---|---|---|
username |
string |
Required. Your username |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
DELETE /users/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. User ID |
GET /ingredients
POST /ingredients
Request body
| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Ingredient name |
GET /ingredients/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Ingredient ID |
PUT /ingredients/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Ingredient ID |
Request body
| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Ingredient name |
DELETE /ingredients/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Ingredient ID |
GET /recipes
Query Parameters
| Parameter | Type | Description |
|---|---|---|
s |
int |
Search term |
minRating |
int |
Minimum rating |
maxRating |
int |
Maximum rating |
minTime |
int |
Minimum preparation time |
maxTime |
int |
Maximum preparation time |
difficulty |
string |
Difficulty of recipe. Available values: easy, medium, hard |
POST /recipes
Request body
| Parameter | Type | Description |
|---|---|---|
title |
string |
Required. The title of the recipe |
description |
string |
Required. The description of the recipe |
steps |
array |
Required. An array of steps for preparing the recipe |
preparation_time |
number |
Required. The preparation time of the recipe (in minutes) |
difficulty |
string |
Required. The difficulty level of the recipe. Available values: easy, medium, hard |
category |
string |
Required. The category of the recipe. Available values: dessert, starter, main course, appetizer, drink, other |
user_id |
string |
Required. The ID of the user who created the recipe |
ingredients |
array |
Required. An array of ingredients required for the recipe |
GET /recipes/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Recipe ID |
PUT /recipes/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Recipe ID |
Request body
| Parameter | Type | Description |
|---|---|---|
title |
string |
Required. The title of the recipe |
description |
string |
Required. The description of the recipe |
steps |
array |
Required. An array of steps for preparing the recipe |
preparation_time |
number |
Required. The preparation time of the recipe (in minutes) |
difficulty |
string |
Required. The difficulty level of the recipe. Available values: easy, medium, hard |
category |
string |
Required. The category of the recipe. Available values: dessert, starter, main course, appetizer, drink, other |
user_id |
string |
Required. The ID of the user who created the recipe |
ingredients |
array |
Required. An array of ingredients required for the recipe |
DELETE /recipes/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Recipe ID |
GET /recipes/latest
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit |
int |
Limit of recipes to retrieve |
GET /recipes/popular
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit |
int |
Limit of recipes to retrieve |
year |
int |
Filter by year |
month |
int |
Filter by month |
GET /recipes/stats
GET /recipes/trending
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit |
int |
Limit of recipes to retrieve |
GET /recipes/user/{username}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
username |
string |
Required. Username of the user whose recipes to retrieve |
GET /recipes/wo-ingredients
Query Parameters
| Parameter | Type | Description |
|---|---|---|
ings |
array |
Required. Ingredients name array |
GET /recipes/ingredients
Query Parameters
| Parameter | Type | Description |
|---|---|---|
ings |
array |
Required. Ingredients name array |
GET /recipes/similar/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
int |
Required. Recipe ID |
GET /recipes/user/{id}/category/{category}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
int |
Required. User ID |
category |
string |
Required. The category of the recipe. Available values: dessert, starter, main course, appetizer, drink, other |
GET /ratings
POST /ratings
Request body
| Parameter | Type | Description |
|---|---|---|
score |
int |
Required. Score of the recipe |
comment |
string |
Required. Comment on the recipe |
recipe_id |
string |
Required. Recipe ID |
GET /ratings/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Rating ID |
PUT /ratings/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Rating ID |
Request body
| Parameter | Type | Description |
|---|---|---|
score |
int |
Required. Score of the recipe |
comment |
string |
Required. Comment on the recipe |
DELETE /ratings/{id}
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Rating ID |
Footnotes
-
Search the internet for jwt secret generator and use it as an environment variable. ↩
