Sample aplication to demo a vertx-realworld-example-app for gothinkster. Built with vertx web to showcase the usage of vertx-boot library.
Git clone the project on your local machine and import it to your favorite ide.
For runnning this, you will need
- Java 1.8
- Gradle support - In Eclipse editor, goto help -> eclipse marketplace -> search for buildship (buildship gradle integration) and install it.
This sample application make use of Vertx-Boot library to expose sample rest APIs for [gothinkster] (gothinkster/realworld#228)
- HttpServerVerticle -> Default verticle from the vertx-boot library.
- DatabaseVerticle -> Database verticle to store the data.
- PingHandler -> Default handler from the vertx-boot library to send a "OK" Json response.
For running the app, (IDE used here is IntelliJ)
- Open appConfig.json file and set the "http_server_port" as per your choice. Also, set "mongo_config".
- Once, changes are done in appConfig.json, add/edit Run/Debug Configurations for the project("vertx-realworld-example-app") and set:
- Main class: com.greyseal.vertx.boot.AppLauncher
- VM options: -Dlogback.configurationFile=file:../vertx-realworld-example-app/src/main/resources/logback.xml
- Program arguments: run com.greyseal.vertx.boot.verticle.MainVerticle -conf ../vertx-realworld-example-app/src/main/resources/appConfig.json
- Environment variables: ENV=dev. Make sure to set this variable.
After setting the variables, Run/Debug the project. If app starts successfully, then try
Type: GET http://localhost:8080/runner/ping
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479fadddda
Response
{
"status": "OK"
}
That's it.
- Create user without authentication or signup
Type: POST http://localhost:8080/runner/users
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"user": {
"email": "[email protected]",
"password": "p",
"userName": "johnjacob",
"bio":"S/w",
"image":"/image"
}
}
Response:
{
"id": "5b8cd8a7ad813c83f5cfcba5"
}
- To perform login or authentication
Type: POST http://localhost:8080/runner/users
Headers: Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"user": {
"email": "[email protected]",
"password": "p"
}
}
Response:
{
"email": "[email protected]",
"userName": "johnjacobs"
}
Response Headers
Authorization → BEARER 8a2d6bdfd56b4a2a87009c1bbdca6c14
- To perform update to user model. This needs authentication token from the above API response
Type: PUT http://localhost:8080/runner/users
Headers: AUTHORIZATION: BEARER 69991c4e2ffd44968e017d1d83e1a9ec Content-Type: application/json; Trace-Id: c1d887063c3e492b9951b0479faddddu
Request body:
{
"user": {
"email": "[email protected]",
"password": "pa",
"userName": "johnjacobsd",
"bio":"acc",
"image":"/image/ima"
}
}
Response:
{
"bio": "acc",
"image": "/image/ima",
"userName": "johnjacobsd",
"updatedBy": {
"$oid": "5b891df4ad813c331cd8a7ab"
}
}
Response Headers
Authorization → BEARER 8a2d6bdfd56b4a2a87009c1bbdca6c14