WIP: feat: NCS-38 Http4s server #26
Reference in New Issue
Block a user
Delete Branch "feat/NCS-38"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
IMPORTANT NOTE: DO NOT MERGE THIS PR AS STATED IN THE TICKET DESCRIPTION.
This code is not covered by the tests because this will not go into production.
Added http4s server according to the API specification. A game is playable via API.
Summary
servermodule implementing the OpenAPI spec fromdocs/api-spec.yaml./gradlew :modules:server:runon0.0.0.0:8080Endpoints
All routes are under
/api/board/game/...following the lichess board/bot split convention, reserving/api/bot/game/...for a future bot API.POST /{id}/move/{uci}, legal moves, undo, redoArchitecture
GameRegistry— thread-safe in-memory game store (Ref[IO, Map[String, GameEntry]])GameEntry— wrapsGameEnginewith an internalObserverthat captures terminal state (checkmate, stalemate,draw) before the engine resets its context
BoardRoutes— singleHttpRoutes.of[IO]block, each case delegates to a private handlerServerApp—IOAppentry point;ServerLaunchernot included (kept separate fromuito avoid cross-moduleIOAppresolution issues with Scala 3)ui)Test plan
./compilepasses clean./gradlew :modules:server:runstarts without errorsPOST /api/board/gamereturns aGameFullDtowith a fresh gamePOST /api/board/game/{id}/move/e2e4returns updated state withturn: "black"GET /api/board/game/{id}/moves?square=e4returns legal moves from e4POST /api/board/game/import/fenwith a valid FEN returns a new gameGET /api/board/game/{id}/export/pgnreturns PGN textPOST /api/board/game/{id}/resignreturns{"ok": true}404withGAME_NOT_FOUNDerror code400withINVALID_MOVEerror codePull request closed