Skip to content

Commit

Permalink
Add some forum endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed May 8, 2024
1 parent 39d9464 commit 22b0f0f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 12 deletions.
23 changes: 11 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ inThisBuild(
Seq(
scalaVersion := scala213,
versionScheme := Some("early-semver"),
version := "3.0.0-SNAPSHOT",
run / fork := true,
version := "3.0.0-SNAPSHOT",
run / fork := true,
run / javaOptions += "-Dconfig.override_with_env_vars=true",
Compile / doc / sources := Seq.empty,
Compile / doc / sources := Seq.empty,
Compile / packageDoc / publishArtifact := false,
Compile / packageSrc / publishArtifact := false,
resolvers += "lila-maven" at "https://raw.githubusercontent.com/ornicar/lila-maven/master"
Expand All @@ -35,32 +35,31 @@ lazy val core = project
)
)


lazy val play = project
.in(file("play"))
.enablePlugins(PlayScala)
.disablePlugins(PlayFilters)
.settings(
commonSettings,
tpolecatExcludeOptions += ScalacOptions.fatalWarnings,
name := "lila-search",
name := "lila-search-play",
libraryDependencies ++= Seq(
"com.github.ornicar" %% "scalalib" % "7.1.0",
"com.typesafe.play" %% "play-json" % "2.9.4",
"com.typesafe.play" %% "play-json-joda" % "2.9.4"
"com.github.ornicar" %% "scalalib" % "7.1.0",
"com.typesafe.play" %% "play-json" % "2.9.4",
"com.typesafe.play" %% "play-json-joda" % "2.9.4"
),
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
).dependsOn(core)

)
.dependsOn(core)

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

Expand Down
26 changes: 26 additions & 0 deletions modules/api/src/main/smithy/_global.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$version: "2"

namespace lila.search.spec

use alloy#simpleRestJson

@error("server")
@httpError(500)
structure InternalServerError {
@required
message: String
}

structure SearchResponse {
@required
hitIds: Ids
}

list Ids {
member: String
}

structure CountResponse {
@required
count: Integer
}
46 changes: 46 additions & 0 deletions modules/api/src/main/smithy/forum.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$version: "2"

namespace lila.search.spec

use alloy#simpleRestJson

@simpleRestJson
service SearchService {
version: "3.0.0",
operations: [SearchForum]
}

@readonly
@http(method: "POST", uri: "/search/forum/{from}/{size}", code: 200)
operation SearchForum {
input: SearchForumInput
output: SearchResponse
errors: [InternalServerError]
}

@readonly
@http(method: "POST", uri: "/count/forum", code: 200)
operation CountForum {
input: ForumInputBody
output: CountResponse
errors: [InternalServerError]
}

structure SearchForumInput {

@required
body: ForumInputBody

@required
@httpLabel
from: Integer

@required
@httpLabel
size: Integer
}

structure ForumInputBody {
troll: Boolean
query: String
}

0 comments on commit 22b0f0f

Please sign in to comment.