Skip to content

keuss/springboot-restservices-sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

springboot-restservices-sandbox

springboot-restservices-sandbox with :

  • REST controllers (GET, POST, DELETE, and PATCH)
  • Spring DATA and h2 database in runtime
  • Swagger2
  • React JS frontend in springboot's resources

Build and RUN

  • mvn clean package (build back and front with npm and browserify, all incluse)
  • java -jar target/springboot-restservices-sandbox-0.1.0.jar (use Embedded Tomcat), see http://localhost:8080/api/users (to change port : -Dserver.port=XXXX for instance : java -Dserver.port=8888 -jar target/springboot-restservices-sandbox-0.1.0.jar)
  • for the IU : http://localhost:8080/api

Tests services & controllers

DATA h2

INSERT INTO public.users(id, name, email, userdetail) VALUES (0, 'gui', '[email protected]', '{"postsNb": 11, "followersNb": 2, "followingNb": 0, "suggestions": [2, 3, 4, 5]}');

Frontend

alt tag

JSON user

  {
    "id": 0,
    "name": "gui",
    "email": "[email protected]",
    "userDetail": {
      "postsNb": 11,
      "followersNb": 2,
      "followingNb": 0,
      "suggestions": [2, 3]
    }
  }
  
  Patch examples :
  
  [{
  	"op": "replace",
  	"path": "/userDetail/followingNb",
  	"value": 111
  }]

  Or :
  
  [{
   "op": "replace",
   "path": "/userDetail",
   "value": {
    "postsNb": 111,
    "followersNb": 222,
    "followingNb": 333,
    "suggestions": [444]
   }
  }]

  Or (Adds a value to an object or inserts it into an array.
  In the case of an array, the value is inserted before the given index.
  The - character can be used instead of an index to insert at the end of an array. see http://jsonpatch.com/) :

  [{
  	"op": "add",
  	"path": "/userDetail/suggestions/-",
  	"value": 4
  }]
  
  

DevTools

Add :

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

alt tag

Links