initial way to run the server:
sbt:backend> assembly java -jar backend/target/scala-3.2.0/backend-assembly-0.1.0-SNAPSHOT.jar
This commit is contained in:
parent
1f7fdfb387
commit
329dc6e8b2
|
@ -22,16 +22,12 @@ object MyHttpService {
|
||||||
|
|
||||||
val authedRoomRoutes: AuthedRoutes[(PlayerID, RoomID), IO] =
|
val authedRoomRoutes: AuthedRoutes[(PlayerID, RoomID), IO] =
|
||||||
AuthedRoutes.of {
|
AuthedRoutes.of {
|
||||||
case GET -> Root / subscribe as (playerId, roomId) => {
|
case GET -> Root / "subscribe" as (playerId, roomId) => {
|
||||||
val send: Stream[IO, WebSocketFrame] =
|
val send: Stream[IO, WebSocketFrame] =
|
||||||
{
|
Stream
|
||||||
val a = Stream
|
|
||||||
.emits(TestModels.testChangesList)
|
.emits(TestModels.testChangesList)
|
||||||
.covary[IO].metered(5.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
|
.covary[IO].metered(5.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
|
||||||
Stream
|
|
||||||
.awakeEvery[IO](1.seconds)
|
|
||||||
.map(_ => WebSocketFrame.Text("text"))
|
|
||||||
}
|
|
||||||
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
|
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
|
||||||
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))
|
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))
|
||||||
case other => Sync[IO].delay(println(other))
|
case other => Sync[IO].delay(println(other))
|
||||||
|
@ -40,13 +36,13 @@ object MyHttpService {
|
||||||
}
|
}
|
||||||
case GET -> Root / "vote" / vote as (playerId, roomId) => {
|
case GET -> Root / "vote" / vote as (playerId, roomId) => {
|
||||||
// TODO forward these to the service implementation
|
// TODO forward these to the service implementation
|
||||||
Ok(s">> got $vote from $playerId in $roomId")
|
IO(println(s">> got $vote from $playerId in $roomId")) >> Ok()
|
||||||
}
|
}
|
||||||
case GET -> Root / "end-voting" as (playerId, roomId) => {
|
case GET -> Root / "end-voting" as (playerId, roomId) => {
|
||||||
Ok(s">> got request to end voting from $playerId in $roomId")
|
IO(println(s">> got request to end voting from $playerId in $roomId")) >> Ok()
|
||||||
}
|
}
|
||||||
case GET -> Root / "new-poll" as (playerId, roomId) => {
|
case GET -> Root / "new-poll" as (playerId, roomId) => {
|
||||||
Ok(s">> got request to start new voting from $playerId in $roomId")
|
IO(println(s">> got request to start new voting from $playerId in $roomId")) >> Ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +51,7 @@ object MyHttpService {
|
||||||
|
|
||||||
val authenticationRoute = HttpRoutes
|
val authenticationRoute = HttpRoutes
|
||||||
.of[IO] {
|
.of[IO] {
|
||||||
case req @ POST -> Root / login => {
|
case req @ POST -> Root / "login" => {
|
||||||
for {
|
for {
|
||||||
data <- req.as[Requests.LogIn]
|
data <- req.as[Requests.LogIn]
|
||||||
authResult <- auth.accessRoom(
|
authResult <- auth.accessRoom(
|
||||||
|
@ -76,7 +72,6 @@ object MyHttpService {
|
||||||
}
|
}
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
case _ => Ok("hello")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(authenticationRoute <+> authMiddleware(authedRoomRoutes)).orNotFound
|
(authenticationRoute <+> authMiddleware(authedRoomRoutes)).orNotFound
|
||||||
|
|
|
@ -52,7 +52,8 @@ lazy val backend = project
|
||||||
// available for 2.12, 2.13, 3.2
|
// available for 2.12, 2.13, 3.2
|
||||||
libraryDependencies += "co.fs2" %% "fs2-core" % "3.6.1",
|
libraryDependencies += "co.fs2" %% "fs2-core" % "3.6.1",
|
||||||
libraryDependencies += "org.typelevel" %% "cats-core" % "2.9.0",
|
libraryDependencies += "org.typelevel" %% "cats-core" % "2.9.0",
|
||||||
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.9"
|
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.9",
|
||||||
|
assembly / mainClass := Some("industries.sunshine.planningpoker.BackendApp"),
|
||||||
)
|
)
|
||||||
.dependsOn(common.jvm)
|
.dependsOn(common.jvm)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
pkgs.nodejs
|
pkgs.nodejs
|
||||||
pkgs.sbt
|
pkgs.sbt
|
||||||
pkgs.scalafmt
|
pkgs.scalafmt
|
||||||
|
pkgs.jdk
|
||||||
# pkgs.nodePackages.tailwindcss
|
# pkgs.nodePackages.tailwindcss
|
||||||
# pkgs.nodePackages.postcss
|
# pkgs.nodePackages.postcss
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1")
|
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1")
|
||||||
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
|
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
|
||||||
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
||||||
|
|
Loading…
Reference in New Issue