Skip to content

This is an example of how ZIO ecosystem and tapir library can be used to build a mature API server.

Notifications You must be signed in to change notification settings

lvitaly/zio-tapir-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Made in Ukraine

zio-tapir-example

This is an example of how ZIO ecosystem and tapir library can be used to build a mature API server. The project uses Scala 3, but almost the same code can be adopted to build a project with Scala 2.13 or even with Scala 2.12.

Quick start

JDK and sbt are required.

If you don't have sbt installed and you are a Nix user, you can use Nix-shell with all required dependencies with the following command:

nix develop

Otherwise, you need to install sbt, and afterward, you can use the standard commands:

sbt compile # build the project
sbt test # run the tests
sbt reStart # run the application (Main)
sbt reStop # stop the application (Main)

Features

After application started, you will see next message in the console:

rootProject 2024-04-05 23:16:38,120 | INFO | ZScheduler-Worker-6 | c.l.a.s.Server$package | Go to http://localhost:8000/docs for Swagger UI

You can reach Swagger UI by the http://localhost:8000/docs link and Prometheus metrics by the http://localhost:8000/metrics link. To access authorized endpoints, use the auth.token from the application.conf file. Please note that this authorization technique is used only for example purposes. In real life, you should consider proper access management solutions.

Todo list

  • Create a basic API to query books
  • Remove usage of package objects cause it's deprecated in the Scala 3 (see here)
  • Add DB layer
  • Add tests

Links:

About

This is an example of how ZIO ecosystem and tapir library can be used to build a mature API server.

Resources

Stars

Watchers

Forks