Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danijeldragicevic/recipes-rest-service
Service who is able to create, update, search and delete recipes.
https://github.com/danijeldragicevic/recipes-rest-service
h2-database hyperskill-solutions java-11 project-lombok spring-boot spring-jpa spring-mvc spring-security spring-validation
Last synced: about 1 month ago
JSON representation
Service who is able to create, update, search and delete recipes.
- Host: GitHub
- URL: https://github.com/danijeldragicevic/recipes-rest-service
- Owner: danijeldragicevic
- License: apache-2.0
- Created: 2022-07-04T12:27:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-13T16:09:49.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T10:35:48.944Z (3 months ago)
- Topics: h2-database, hyperskill-solutions, java-11, project-lombok, spring-boot, spring-jpa, spring-mvc, spring-security, spring-validation
- Language: Java
- Homepage:
- Size: 90.8 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Recipes REST service
Backend service who is able to crete, update, search and delete recipes.
- Only registered users can create and see recipes.
- Recipes can be updated and deleted only by the users who created them.Service use embedded H2 database and Basic authentication.
# Technology
- Java 11
- Spring Boot 2.7.1 (Spring Web MVC, Spring Data Jpa, Spring Security, Spring Validation, Project Lombok, H2 database)
- Gradle 7.4# To run application:
Navigate to the project root directory and run **./gradlew bootRun**# Exposed endpoints:
By default, service will run on **http://localhost:8881**
Following endpoints will be exposed:| Methods | Urls | Actions |
|---------|--------------------------------------|---------------------------------------------|
| POST | /api/register | Register new user |
| POST | /api/recipe/new | Create new recipe |
| GET | /api/recipe/:id | Get recipe by :id |
| GET | /api/recipe/search?category=[keyword] | Find all recipes with the category :keyword |
| GET | /api/recipe/search?name=[keyword] | Find all recipes with the name :keyword |
| PUT | /api/recipe/:id | Update recipe by :id |
| DELETE | /api/recipe/:id | Delete recipe by :id |# Examples
**Example 1:** POST /api/recipe/new request without authentication
```
{
"name": "Fresh Mint Tea",
"category": "beverage",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water", "honey", "fresh mint leaves"],
"directions": ["Boil water", "Pour boiling hot water into a mug", "Add fresh mint leaves", "Mix and let the mint leaves seep for 3-5 minutes", "Add honey and mix again"]
}
```
Status code: 401 (Unauthorized)**Example 2:** POST /api/register request without authentication
```
{
"email": "[email protected]",
"password": "RecipeInBinary"
}
```
Status code: 200 (Ok)Further, POST /api/recipe/new request with basic authentication; email (login): [email protected], and password: RecipeInBinary
```
{
"name": "Mint Tea",
"category": "beverage",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water", "honey", "fresh mint leaves"],
"directions": ["Boil water", "Pour boiling hot water into a mug", "Add fresh mint leaves", "Mix and let the mint leaves seep for 3-5 minutes", "Add honey and mix again"]
}
```
Response:
```
{
"id": 1
}
```Further, PUT /api/recipe/1 request with basic authentication; email (login): [email protected], password: RecipeInBinary
```
{
"name": "Fresh Mint Tea",
"category": "beverage",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water", "honey", "fresh mint leaves"],
"directions": ["Boil water", "Pour boiling hot water into a mug", "Add fresh mint leaves", "Mix and let the mint leaves seep for 3-5 minutes", "Add honey and mix again"]
}
```
Status code: 204 (No Content)Further, GET /api/recipe/1 request with basic authentication; email (login): [email protected], password: RecipeInBinary
Response:
```
{
"name": "Fresh Mint Tea",
"category": "beverage",
"date": "2020-01-02T12:11:25.034734",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water", "honey", "fresh mint leaves"],
"directions": ["Boil water", "Pour boiling hot water into a mug", "Add fresh mint leaves", "Mix and let the mint leaves seep for 3-5 minutes", "Add honey and mix again"]
}
```**Example 3:** POST /api/register request without authentication
```
{
"email": "[email protected]",
"password": "C00k1es."
}
```
Status code: 200 (Ok)Further, response for the GET /api/recipe/1 request with basic authentication; email (login): [email protected], password: C00k1es.
```
{
"name": "Fresh Mint Tea",
"category": "beverage",
"date": "2020-01-02T12:11:25.034734",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water", "honey", "fresh mint leaves"],
"directions": ["Boil water", "Pour boiling hot water into a mug", "Add fresh mint leaves", "Mix and let the mint leaves seep for 3-5 minutes", "Add honey and mix again"]
}
```Further, PUT /api/recipe/1 request with basic authentication; email (login): [email protected], password: C00k1es.
```
{
"name": "Warming Ginger Tea",
"category": "beverage",
"description": "Ginger tea is a warming drink for cool weather, ...",
"ingredients": ["1 inch ginger root, minced", "1/2 lemon, juiced", "1/2 teaspoon manuka honey"],
"directions": ["Place all ingredients in a mug and fill with warm water (not too hot so you keep the beneficial honey compounds in tact)", "Steep for 5-10 minutes", "Drink and enjoy"]
}
```
Status code: 403 (Forbidden)Further, DELETE /api/recipe/1 request with basic authentication; email (login): [email protected], password: C00k1es.
Status code: 403 (Forbidden)# Licence
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)