Giter VIP home page Giter VIP logo

books-rest-api's Introduction

Práctica 1. Web y API REST con Spring

Description

Aplicación web que incluye con un listado de libros y comentarios de cada libro, la aplicación también incluye una API REST. La aplicación consta de dos Controllers, uno para la API Rest y otro que maneja la aplicación web sirviendo las templates de Mustache, un Servicio que maneja la lógica de negocio y el acceso a los datos, y luegos las clases de Modelo. No hay base de datos, solo almacenamiento en memoria, donde se almancenan libros y sus comentarios en la misma estructura.

private ConcurrentMap<Long, Book> books = new ConcurrentHashMap<>();

En un primer diseño el almacenamiento consistia en dos Maps:

private ConcurrentMap<Long, Book> books = new ConcurrentHashMap<>();
private ConcurrentMap<Pair(Long,Long), Comment> comment = new ConcurrentHashMap<>();

Había dos Servicios y en ellos se accedía a las estructuras de datos, Comment se accedía usando el BookId y el CommentId, al final se optó por la simplicidad de mantener los Comments en la misma estructura de los Books.

Technologies used

Requirements

  • Java 17
  • Maven 3.5 or higher

Documentation

Build

mvn clean verify

Genera el executable jar dentro de /target, la OpenAPI spec y el OpenAPI html dentro de la carpeta /api-docs

Setup

Spring boot application:

> mvn spring:boot run

or

> java -jar ./target/holamundo-spring-0.0.1-SNAPSHOT.jar

Hay multiples maneras de ejecutar una aplicación de Spring Boot, la documentación explica varias de ellas:

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-running-your-application.html

How to test

Durante el arranque de la aplicación se genera test-data, 5 libros (con Ids 1-5) con 2 comentarios cada uno (con Ids 1-2), con datos aleatorios. Se pueden probar los endpoints usando la Postman collection incluida:

books-rest-api's People

Contributors

renovate[bot] avatar torrespro avatar

Watchers

 avatar  avatar

books-rest-api's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

maven
pom.xml
  • org.springframework.boot:spring-boot-starter-parent 2.6.0
  • com.github.javafaker:javafaker 1.0.2
  • org.springdoc:springdoc-openapi-ui 1.5.12
  • io.github.wimdeblauwe:error-handling-spring-boot-starter 1.7.0
  • org.springdoc:springdoc-openapi-maven-plugin 1.3
  • org.openapitools:openapi-generator-maven-plugin 5.3.0
  • com.coderplus.maven.plugins:copy-rename-maven-plugin 1.0
maven-wrapper
.mvn/wrapper/maven-wrapper.properties
  • maven 3.8.3
  • maven-wrapper 0.5.6

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.