diff --git a/build.sbt b/build.sbt index fdc25c43..7e87aa7b 100644 --- a/build.sbt +++ b/build.sbt @@ -55,7 +55,15 @@ lazy val play = project ).dependsOn(core) +lazy val api = (project in file("modules/api")) + .enablePlugins(Smithy4sCodegenPlugin) + .settings( + name := "api", + libraryDependencies ++= Seq( + "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value, + ) + ) + lazy val root = project .in(file(".")) - .aggregate(core, play) - + .aggregate(core, play, api) diff --git a/modules/api/src/main/smithy/health.smithy b/modules/api/src/main/smithy/health.smithy new file mode 100644 index 00000000..d0e4fd1f --- /dev/null +++ b/modules/api/src/main/smithy/health.smithy @@ -0,0 +1,27 @@ +$version: "2" + +namespace lila.search.spec + +use alloy#simpleRestJson + +@simpleRestJson +service HealthService { + version: "3.0.0", + operations: [HealthCheck] +} + +@readonly +@http(method: "GET", uri: "/health", code: 200) +operation HealthCheck { + output: HealthStatusOutput +} + +enum ElasticStatus { + Ok = "ok" + Unreachable = "unreachable" +} + +structure HealthStatusOutput { + @required + elastic: ElasticStatus +} diff --git a/project/plugins.sbt b/project/plugins.sbt index d3bf0eb5..a7f62784 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +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("org.typelevel" % "sbt-tpolecat" % "0.5.1") diff --git a/smithy-build.json b/smithy-build.json new file mode 100644 index 00000000..0ebf6669 --- /dev/null +++ b/smithy-build.json @@ -0,0 +1,16 @@ +{ + "version": "1.0", + "maven": { + "dependencies": [ + "com.disneystreaming.smithy4s:smithy4s-protocol:0.18.15", + "com.disneystreaming.alloy:alloy-core:0.1.21", + "com.disneystreaming.alloy:alloy-core:0.3.4" + ], + "repositories": [] + }, + "imports": [ + "./src", + "modules/smithy/src/main/smithy", + "modules/smithy/target/scala-3.4.1/src_managed/main/smithy" + ] +} \ No newline at end of file