butcherless / tapir-learn

Learning to build APIs with Scala Tapir
2 stars 1 forks source link

tapir-learn

Learning to build APIs with Scala Tapir

Scala CI

Scala Steward badge

Quick start up

Run the following commands for quick startup and check

  1. git clone https://github.com/butcherless/tapir-learn.git
  2. cd tapir-learn
  3. sbt
  4. aviation-api/reStart
  5. http://localhost:8080/docs
  6. aviation-web/reStart
  7. http://localhost:8081/docs
  8. tapir-webapp/reStart
  9. http://localhost:8080/docs

Project structure

Sbt build tool config file

build.sbt

JVM options for Sbt

.jvmopts

Sbt version

project/build.properties

Project dependencies

project/Dependencies

Sbt plugins

project/plugins.sbt

Compile and run this project

Run Sbt build tool

sbt

Compile the application

compile or ~compile for continuous compiling

Manage the web server with Revolver plugin

reStart, reStop, reStatus, or ~reStart

Check Swagger API:

Check Health endpoint (Akka)

http://localhost:8080/api/v1.0/health

curl -v http://localhost:8080/api/v1.0/health | jq

Run the test suites

test or ~test for continuous testing

Reload changes in build.sbt config file

reload

Clean target working directory

clean

Check dependencies with command line and browser

dependencyUpdates, dependencyBrowseTree, dependencyList, dependencyTree

Exit Sbt

CTRL + D

Testing

Rapid test cycle via continuous testing with a single suite test:

~testOnly com.cmartin.learn.api.ActuatorApiSpec

Rapid test cycle via continuous testing with a single test:

~testOnly com.cmartin.learn.api.ActuatorApiSpec -- -z "keyword"

Integration

module: tapir-webapp/reStart

bash command: httpie

http -v "http://localhost:8080/api/v1.0/health"
http -v "http://localhost:8080/api/v1.0/transfers/1"
http -v "http://localhost:8080/api/v1.0/transfers/404"
http -v "http://localhost:8080/api/v1.0/transfers/500"
echo '{"sender":"ES11 0182 1111 2222 3333 4444",
       "receiver":"ES99 2038 9999 8888 7777 6666",
       "amount":100.0,
       "currency":"EUR",
       "date":"2020-11-07T08:05:13.345Z",
       "desc":"Viaje a Tenerife"}' \
 |  http -v http://localhost:8080/api/v1.0/transfers

Logback config

Asynchronous non-blocking appender config

Akka config

Basic standard configuration

https://doc.akka.io/docs/akka/current/general/configuration.html

tapir-webapp/src/main/resources/application.conf

Links: