feat(server): Http4s server
Build & Test (NowChessSystems) TeamCity build failed

Changed at how the run command starts TUI GUI and the server. This is neccessary so that TUI GUI and server start and the game from the TUI/GUI is registered in the server.
This commit is contained in:
LQ63
2026-04-12 18:50:47 +02:00
parent 25c113e4d5
commit df675a5f08
4 changed files with 34 additions and 3 deletions
@@ -0,0 +1,25 @@
package de.nowchess.server
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import com.comcast.ip4s.{host, port}
import de.nowchess.api.player.{PlayerId, PlayerInfo}
import de.nowchess.chess.engine.GameEngine
import org.http4s.ember.server.EmberServerBuilder
object ServerLauncher:
def start(engine: GameEngine): String =
val white = PlayerInfo(PlayerId("white"), "Player 1")
val black = PlayerInfo(PlayerId("black"), "Player 2")
(for
registry <- GameRegistry.make
_ <- EmberServerBuilder
.default[IO]
.withHost(host"0.0.0.0")
.withPort(port"8080")
.withHttpApp(BoardRoutes(registry).routes.orNotFound)
.build
.useForever
.start
gameId <- registry.add(GameEntry(engine, white, black))
yield gameId).unsafeRunSync()