Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
move domain to commons and use circe for http4s version only
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMtnez committed Oct 27, 2023
1 parent c6460f2 commit be40bb1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 29 deletions.
8 changes: 2 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ val circeV = "0.14.6"

lazy val common = project
.in(file("common"))
.settings(
name := "todobackend-common",
libraryDependencies ++= Seq(
"io.circe" %% "circe-generic" % circeV
)
)
.settings(name := "todobackend-common")

val http4sV = "1.0.0-M40"
val logbackV = "1.4.11"
Expand All @@ -31,6 +26,7 @@ lazy val `todobackend-http4s` = project
"org.http4s" %% "http4s-ember-server" % http4sV,
"org.http4s" %% "http4s-dsl" % http4sV,
"org.http4s" %% "http4s-circe" % http4sV,
"io.circe" %% "circe-generic" % circeV,
"ch.qos.logback" % "logback-classic" % logbackV,
"org.scalameta" %% "munit" % munitV % Test,
"org.typelevel" %% "munit-cats-effect" % munitCE3V % Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package es.jesusmtnez.todobackend.domain

import io.circe.*
import io.circe.generic.semiauto.*

import java.util.UUID

final case class TodoItem(
Expand All @@ -13,8 +10,6 @@ final case class TodoItem(
)

object TodoItem:
given Codec[TodoItem] = deriveCodec

private val baseUrl: String = "http://localhost:8080"

def uncompleted(id: UUID, title: String, order: Int): TodoItem =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package es.jesusmtnez.todobackend.domain

final case class TodoRequest(
title: String,
order: Option[Int]
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package es.jesusmtnez.todobackend.domain

import io.circe.Decoder
import io.circe.generic.semiauto.deriveDecoder

final case class TodoUpdate(
title: Option[String],
completed: Option[Boolean],
order: Option[Int]
)

object TodoUpdate:
given Decoder[TodoUpdate] = deriveDecoder
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import buildinfo.BuildInfo
import cats.effect.*
import cats.syntax.all.*
import es.jesusmtnez.todobackend.domain.*
import io.circe.*
import io.circe.generic.semiauto.*
import org.http4s.HttpRoutes
import org.http4s.circe.*
import org.http4s.dsl.Http4sDsl
Expand All @@ -21,6 +23,10 @@ object TodoBackendRoutes:
val dsl = new Http4sDsl[F] {}
import dsl._

implicit val todoItemCodec: Codec[TodoItem] = deriveCodec
implicit val todoRequestDecoder: Decoder[TodoRequest] = deriveDecoder
implicit val todoUpdateDecoder: Decoder[TodoUpdate] = deriveDecoder

import org.http4s.circe.CirceEntityCodec.*

HttpRoutes.of[F]:
Expand Down

This file was deleted.

0 comments on commit be40bb1

Please sign in to comment.