Skip to content

Commit

Permalink
remove scodec parts
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicoulaud-ledger committed Nov 4, 2023
1 parent 98039bf commit fdf8756
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 90 deletions.
18 changes: 8 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ inThisBuild(
scalaVersion := "3.3.1"
)

lazy val api = Project("api", file("modules/api"))
lazy val api = project.in(file("modules/api"))
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.10.0",
"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.8.5",
"com.softwaremill.sttp.tapir" %% "tapir-iron" % "1.8.5",
"io.circe" %% "circe-core" % "0.14.6",
"org.scodec" %% "scodec-core" % "2.2.2",
"org.scodec" %% "scodec-bits" % "1.1.38",
"io.github.iltotore" %% "iron" % "2.3.0",
"io.github.iltotore" %% "iron-cats" % "2.3.0",
"io.github.iltotore" %% "iron-circe" % "2.3.0"
"org.typelevel" %% "cats-core" % "2.10.0",
"com.softwaremill.sttp.tapir" %% "tapir-core" % "1.8.5",
"com.softwaremill.sttp.tapir" %% "tapir-iron" % "1.8.5",
"io.circe" %% "circe-core" % "0.14.6",
"io.github.iltotore" %% "iron" % "2.3.0",
"io.github.iltotore" %% "iron-cats" % "2.3.0",
"io.github.iltotore" %% "iron-circe" % "2.3.0"
)
)
5 changes: 0 additions & 5 deletions modules/api/src/main/scala/common/iron/constraint/all.scala

This file was deleted.

20 changes: 0 additions & 20 deletions modules/api/src/main/scala/common/iron/constraint/scodec.scala

This file was deleted.

36 changes: 0 additions & 36 deletions modules/api/src/main/scala/common/scodec/codecs.scala

This file was deleted.

24 changes: 5 additions & 19 deletions modules/api/src/main/scala/common/types.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package common

import _root_.scodec.bits
import _root_.scodec.bits.ByteVector
import cats.syntax.all.*
import cats.Order
import cats.Show
import common.circe.codecs.given
import common.iron.constraint.all.*
import common.iron.constraint.all.given
import common.scodec.codecs.ByteVectorCodecs
import common.scodec.codecs.ByteVectorCodecs.Base64
import common.tapir.syntax.*
import io.circe.Codec as CirceCodec
import io.github.iltotore.iron.*
Expand All @@ -20,19 +14,11 @@ import sttp.tapir.Codec.PlainCodec as TapirPlainCodec
import sttp.tapir.Codec as TapirCodec
import sttp.tapir.Schema as TapirSchema

private type PayloadConstraints = DescribedAs[MaxLengthL[1048576L], "Payload must be 1MB max"]
opaque type Payload = ByteVector :| PayloadConstraints
object Payload extends RefinedTypeOps[ByteVector, PayloadConstraints, Payload], Base64, TapirCodecIron:
given CirceCodec[Payload] = summon[CirceCodec[ByteVector]].iemap(either(_))(_.value)
given TapirPlainCodec[Payload] = summon[TapirPlainCodec[ByteVector]].iemap(either(_))(_.value)
given TapirSchema[Payload] = ironTypeSchema[ByteVector, PayloadConstraints]
given Show[Payload] = summon[Show[ByteVector]].contramap(_.value)

private type VersionConstraints = DescribedAs[GreaterEqual[0], "Version must be positive"]
opaque type Version = Int :| VersionConstraints
opaque type Version = Int :| VersionConstraints
object Version extends RefinedTypeOps[Int, VersionConstraints, Version], TapirCodecIron:
given CirceCodec[Version] = summon[CirceCodec[Int]].iemap(either(_))(_.value)
given CirceCodec[Version] = summon[CirceCodec[Int]].iemap(either(_))(_.value)
given TapirPlainCodec[Version] = summon[TapirPlainCodec[Int]].iemap(either(_))(_.value)
given TapirSchema[Version] = ironTypeSchema[Int, VersionConstraints]
given Order[Version] = Order.fromOrdering
given Show[Version] = summon[Show[Int]].contramap(_.value)
given TapirSchema[Version] = ironTypeSchema[Int, VersionConstraints]
given Order[Version] = Order.fromOrdering
given Show[Version] = summon[Show[Int]].contramap(_.value)

0 comments on commit fdf8756

Please sign in to comment.