Skip to content

Commit

Permalink
Add client module
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed May 9, 2024
1 parent 7a39343 commit fca28f3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ fileOverride {
runner.dialect = scala213
}

"glob:**/modules/api/**" {
runner.dialect = scala3
}

"glob:**/modules/client/**" {
runner.dialect = scala3
}

"glob:**/modules/app/**" {
runner.dialect = scala3
}

}
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,22 @@ lazy val api = (project in file("modules/api"))
.settings(
scalaVersion := scala3,
name := "lila-search-api",
smithy4sWildcardArgument := "?",
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value
)
)

lazy val client = (project in file("modules/client"))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
scalaVersion := scala3,
name := "lila-search-client",
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value
)
).dependsOn(api)

lazy val app = (project in file("modules/app"))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
Expand Down
19 changes: 19 additions & 0 deletions modules/client/src/main/scala/IOClient.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package lila.search
package client

import smithy4s.http4s.*
import org.http4s.Uri
import org.http4s.client.Client
import cats.effect.IO
import cats.effect.Resource

// the package under which the scala code was generated
import lila.search.spec.*

object Clients:
def apply(http4sClient: Client[IO], uri: Uri): Resource[IO, SearchService[IO]] =
SimpleRestJsonBuilder
.apply(SearchService)
.client(http4sClient)
.uri(uri)
.resource
30 changes: 30 additions & 0 deletions project/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version = "3.8.1"
runner.dialect = scala213

align.preset = more
maxColumn = 110
spaces.inImportCurlyBraces = true
rewrite.rules = [SortModifiers]
rewrite.redundantBraces.stringInterpolation = true

fileOverride {
"glob:**/build.sbt" {
runner.dialect = scala213
}
"glob:**/project/**" {
runner.dialect = scala213
}

"glob:**/modules/api/**" {
runner.dialect = scala3
}

"glob:**/modules/client/**" {
runner.dialect = scala3
}

"glob:**/modules/app/**" {
runner.dialect = scala3
}

}
5 changes: 2 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.18.16")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

0 comments on commit fca28f3

Please sign in to comment.