diff --git a/.scalafmt.conf b/.scalafmt.conf index a281cdc6..e87d759c 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -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 } + } diff --git a/build.sbt b/build.sbt index 6454b038..f48389af 100644 --- a/build.sbt +++ b/build.sbt @@ -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( diff --git a/modules/client/src/main/scala/IOClient.scala b/modules/client/src/main/scala/IOClient.scala new file mode 100644 index 00000000..c89e426d --- /dev/null +++ b/modules/client/src/main/scala/IOClient.scala @@ -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 diff --git a/project/.scalafmt.conf b/project/.scalafmt.conf new file mode 100644 index 00000000..e87d759c --- /dev/null +++ b/project/.scalafmt.conf @@ -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 + } + +} diff --git a/project/plugins.sbt b/project/plugins.sbt index a7f62784..5f862f5a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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