diff --git a/api/build.sbt b/api/build.sbt index 811ba02..4bde5b1 100644 --- a/api/build.sbt +++ b/api/build.sbt @@ -6,19 +6,16 @@ resolvers += "Akka library repository" at "https://repo.akka.io/maven" enablePlugins(JavaAppPackaging) -val scalatestVersion = "3.2.18" val AkkaVersion = "2.9.3" -val AkkaHttpVersion = "10.6.3" -val MongoDBVersion = "5.1.0" libraryDependencies ++= { Seq( - "org.scalatest" %% "scalatest" % scalatestVersion % "test", + "org.scalatest" %% "scalatest" % "3.2.18" % "test", "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion, "com.typesafe.akka" %% "akka-stream" % AkkaVersion, - "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion, + "com.typesafe.akka" %% "akka-http" % "10.6.3", "org.slf4j" % "slf4j-simple" % "2.0.13", ) } -libraryDependencies += ("org.mongodb.scala" %% "mongo-scala-driver" % MongoDBVersion).cross( +libraryDependencies += ("org.mongodb.scala" %% "mongo-scala-driver" % "5.1.0").cross( CrossVersion.for3Use2_13 ) diff --git a/api/src/main/scala/Routes.scala b/api/src/main/scala/Router.scala similarity index 76% rename from api/src/main/scala/Routes.scala rename to api/src/main/scala/Router.scala index ee863cc..2ec974f 100644 --- a/api/src/main/scala/Routes.scala +++ b/api/src/main/scala/Router.scala @@ -5,7 +5,7 @@ import akka.http.scaladsl.server.Directives.get import akka.http.scaladsl.server.Directives.path import akka.http.scaladsl.server.Route -object Routes { +object Router { val route: Route = path("hello") { @@ -13,5 +13,10 @@ object Routes { complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "

Say hello to akka-http

")) } } + path("health") { + get { + complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "

OK

")) + } + } } diff --git a/api/src/main/scala/Server.scala b/api/src/main/scala/Server.scala index 95b10fb..bd54922 100644 --- a/api/src/main/scala/Server.scala +++ b/api/src/main/scala/Server.scala @@ -9,23 +9,17 @@ import scala.concurrent.duration.Duration object Server { def run() = - while (true) { - println("Hello, world!") - Thread.sleep(1000) - } -// implicit val system = ActorSystem(Behaviors.empty, "my-system") -// implicit val executionContext = system.executionContext -// val keepAlive = Promise[Unit].future -// -// val host = "0.0.0.0" -// val port = 8080 -// -// val bindingFuture = Http() -// .newServerAt(host, port) -// .bind(Routes.route) -// -// Database.test() -// -// Await.result(keepAlive, Duration.Inf) + implicit val system = ActorSystem(Behaviors.empty, "api") + implicit val executionContext = system.executionContext + + val host = "0.0.0.0" + val port = 8080 + + val bindingFuture = Http() + .newServerAt(host, port) + .bind(Router.route) + + val keepAlive = Promise[Unit].future + Await.result(keepAlive, Duration.Inf) }