- Install sbt
- Clone the repo
cd ledger-scala-template
- Install PostgreSQL and configure access for user
postgres
and passwordpostgres
(or change it inModule
) - Create database
users
and tableapi_user
(seesrc/main/resources/db/migration/users.sql
or useFlyway
as in the tests) or according to the config sbt test
(optional)sbt run
curl 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.http
package: Includes custom Circe Json Encoders for value classes.config
object: Includes model related to application config.validation
object: 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