An open API service indexing awesome lists of open source software.

https://github.com/sueszli/spring-boilerplate

boilerplate code for spring boot crud apps with SSE
https://github.com/sueszli/spring-boilerplate

ag-grid java-concurrency server-sent-events spring-boot sse

Last synced: about 2 months ago
JSON representation

boilerplate code for spring boot crud apps with SSE

Awesome Lists containing this project

README

          

boilerplate code for a crud application with the following stack:

- vanilla js (served by spring boot through `src/main/resources/static`)
- AG-Grid
- toastr.js
- axios
- spring boot
- maven
- hibernate, JPA (the JOOQ driver would have been better, but it isn't free for oracle DB)
- lombok, mapstruct
- h2 database
- sse (server sent events) based broadcast and subscription mechanism to allow concurrent writes

# usage

```bash
#
# build
#

# install dependencies (and ignore ssl errors in case you are behind a proxy)
mvn clean install -Dmaven.resolver.transport=wagon -Dmaven.clean.failOnError=false -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true -Dhttps.protocols=TLSv1.2

# list dependencies
mvn dependency:tree

# run with "test" profile
mvn spring-boot:run -Dspring-boot.run.profiles=test

#
# testing
#

# create
curl -X POST http://localhost:8080/api/v1/duck \
-H 'Content-Type: application/json' \
-d '{ "firstName":"larry", "secondName": "larson" }'

# read
curl -X GET http://localhost:8080/api/v1/duck/1
curl -X GET http://localhost:8080/api/v1/duck | json_pp

# update
curl -X PUT http://localhost:8080/api/v1/duck \
-H 'Content-Type: application/json' \
-d '{ "id": 1, "firstName":"updated", "secondName":"updated" }'

# delete
curl -X DELETE http://localhost:8080/api/v1/duck/1
curl -X DELETE http://localhost:8080/api/v1/duck

# sse broadcast
curl -X POST http://localhost:8080/api/v1/sse/broadcast/hello%20everyone!

# sse subscribe
curl -X GET http://localhost:8080/api/v1/sse/subscription

```