Skip to content

bengaly/springboot-book-hexagonal-archi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book manager apis with spring boot based on hexagonal architecture

Hexagonal architecture

To read about hexagonal architecture : https://www.urbanisation-si.com/architecture-hexagonale-un-exemple-de-mise-en-pratique-de-la-methode-ddd-domain-driven-design-1

Stack

  • Spring Web
  • Spring Data JPA
  • Hibernate validator
  • Lombok
  • MapsStruct
  • H2 database

Test: to create a book

Use this endpoint: http://localhost:8080/v1/books

Body value :

{
  "name": "Java for beginners",
  "description": "Java for beginners",
  "numberOfPages": 20
}

Test: to find a book

Use this endpoint: http://localhost:8080/v1/books/:id where id is the identifier of book.

Response:

{
    "id": 1,
    "name": "Java for beginners",
    "description": "Java for beginners",
    "numberOfPages": 20
}

Handling exception cases

Try to create a book with numberOfPages less than 5 or greater than 200, you should receive Bad request error.

Request :

{
  "name": "Java for beginners",
  "description": "Java for beginners",
  "numberOfPages": 2
}

Response:

400 Bad Request

{
    "date": "2022-06-21T12:02:42.934",
    "message": "Validation Failed",
    "details": [
        "A Book should have 5 or more than 5 pages"
    ]
}

About

Demo project for hexagonal architecture with Spring Boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages