- Install sbt
- Clone the repo
cd ledger-scala-template- Install PostgreSQL and configure access for user
postgresand passwordpostgres(or change it inModule) - Create database
usersand tableapi_user(seesrc/main/resources/db/migration/users.sqlor useFlywayas in the tests) or according to the config sbt test(optional)sbt runcurl http://localhost:8080/users/USERNAME
It contains the minimal code to get you started:
UserRepository: Defines a method to find a user without commiting to a Monad (kind of tagless-final).PostgresUserRepository: Implementation of the UserRepository interface using Doobie and PostgreSQL abstracting over the EffectF[_].
UserService: Business logic on top of the UserRepository again abstracting over the EffectF[_].UserHttpEndpoint: Defines the http endpoints of the REST API making use of the UserService.HttpErrorHandler: Mapping business errors to http responses in a single place.httppackage: Includes custom Circe Json Encoders for value classes.configobject: Includes model related to application config.validationobject: Includes fields validation usingcats.data.ValidatedNel.Server: The main application that wires all the components and provide the web server.App: The entrypoint
Be inpired greatly by https://github.com/profunktor/typelevel-stack.g8