Skip to content

RESTful API to discover and explore a universe of recipes.

License

Notifications You must be signed in to change notification settings

JaviGarc1a/DiShared

Repository files navigation

DiShared

RESTful API to discover and explore a universe of recipes.

image

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

DB_URL

JWT_SECRET1

Run Locally

Clone the project

  git clone https://github.com/JaviGarc1a/DiShared.git

Go to the project directory

  cd DiShared

Install dependencies

  npm install

Populate database

  npm run populate

Start the server

  npm start

This project runs on http://localhost:3000. After starting the server, you can access our Swagger documentation at http://localhost:3000/api-doc

API Reference

Authentication

Post auth

  POST /auth/login

Request body

Parameter Type Description
username string Required. Your username
password string Required. Your password

Users

Get all users

  GET /users

Create a new user

  POST /users

Request body

Parameter Type Description
username string Required. Your username
email string Required. Your email
password string Required. Your password

Get an user by ID

  GET /users/{id}

Path Parameters

Parameter Type Description
id string Required. User ID

Update an user by 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 an user by ID

DELETE /users/{id}

Path Parameters

Parameter Type Description
id string Required. User ID

Ingredients

Get all ingredients

  GET /ingredients

Create a new ingredient

  POST /ingredients

Request body

Parameter Type Description
name string Required. Ingredient name

Get an ingredient by ID

  GET /ingredients/{id}

Path Parameters

Parameter Type Description
id string Required. Ingredient ID

Update an ingredient by 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 an ingredient by ID

DELETE /ingredients/{id}

Path Parameters

Parameter Type Description
id string Required. Ingredient ID

Recipes

Get all recipes

  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

Create a new recipe

  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 a recipe by ID

  GET /recipes/{id}

Path Parameters

Parameter Type Description
id string Required. Recipe ID

Update a recipe by 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 a recipe by ID

DELETE /recipes/{id}

Path Parameters

Parameter Type Description
id string Required. Recipe ID

Get a latest recipes

GET /recipes/latest

Query Parameters

Parameter Type Description
limit int Limit of recipes to retrieve

Get a popular recipes

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 a recipes stats

GET /recipes/stats

Get a trending recipes

GET /recipes/trending

Query Parameters

Parameter Type Description
limit int Limit of recipes to retrieve

Get a user's recipe by username

GET /recipes/user/{username}

Path Parameters

Parameter Type Description
username string Required. Username of the user whose recipes to retrieve

Get a recipe without some ingredients

GET /recipes/wo-ingredients

Query Parameters

Parameter Type Description
ings array Required. Ingredients name array

Get a recipe with ingredients

GET /recipes/ingredients

Query Parameters

Parameter Type Description
ings array Required. Ingredients name array

Get a recipe similars by ID

GET /recipes/similar/{id}

Path Parameters

Parameter Type Description
id int Required. Recipe ID

Get a recipe by user and category

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

Ratings

Get all ratings

  GET /ratings

Create a new rating

  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 a rating by ID

  GET /ratings/{id}

Path Parameters

Parameter Type Description
id string Required. Rating ID

Update a rating by 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 an rating by ID

DELETE /ratings/{id}

Path Parameters

Parameter Type Description
id string Required. Rating ID

Authors

Footnotes

  1. Search the internet for jwt secret generator and use it as an environment variable.

About

RESTful API to discover and explore a universe of recipes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages