This project is meant to be a lightweight clone of a popular website where users can store a list of personal links.
It is built using HTTP4S for the server, Circe for encoding, and Doobie for database access. The database is a MySQL instance deployed on PlanetScale (heard good things about it, wanted to try it out), but if you want to use a different database, just change the driver.
If you have any recommendations or pointers, please submit a PR or an Issue.
{ "username": String }
{ "id": Int, "username": String, "createdDate": String }
{ "id": Int, "username": String, "createdDate": String }
{ "userId": Int, "link": String }
{ "id": Int, "link": String, "userId": Int, "createdDate": String }
[ String, String, ... ]
{ "hi": "hello world!" }
- It can be difficult to extract optionals from the Doobie SQL transactions in
DatabaseService.scala
and do the error handling inMain.scala
. For example, in the case of/tree/{username}
we simply check for an empty list to determine the HTTP response code, instead of using pattern matching on an Optional, which would be ideal. - Implicit vals are automatically passed as arguments to the demanding methods. I believe they match on the object's type.
- By default, Doobie absorbs
select *
columns into an object (such as aUser
in this project) the order they are received. You might need to query columns in a specific order, or reorder the case class definition to fit the database schema.