feat: NCS-37 Add initial API structure and DTOs for NowChess application

This commit is contained in:
2026-04-19 21:04:40 +02:00
committed by Janis
parent b50a9eca40
commit 3849885c66
83 changed files with 1107 additions and 1170 deletions
@@ -0,0 +1,3 @@
package de.nowchess.api.dto
final case class ApiErrorDto(code: String, message: String, field: Option[String])
@@ -0,0 +1,6 @@
package de.nowchess.api.dto
final case class CreateGameRequestDto(
white: Option[PlayerInfoDto],
black: Option[PlayerInfoDto],
)
@@ -0,0 +1,6 @@
package de.nowchess.api.dto
final case class ErrorEventDto(`type`: String, error: ApiErrorDto)
object ErrorEventDto:
def apply(error: ApiErrorDto): ErrorEventDto = ErrorEventDto("error", error)
@@ -0,0 +1,8 @@
package de.nowchess.api.dto
final case class GameFullDto(
gameId: String,
white: PlayerInfoDto,
black: PlayerInfoDto,
state: GameStateDto,
)
@@ -0,0 +1,6 @@
package de.nowchess.api.dto
final case class GameFullEventDto(`type`: String, game: GameFullDto)
object GameFullEventDto:
def apply(game: GameFullDto): GameFullEventDto = GameFullEventDto("gameFull", game)
@@ -0,0 +1,12 @@
package de.nowchess.api.dto
final case class GameStateDto(
fen: String,
pgn: String,
turn: String,
status: String,
winner: Option[String],
moves: List[String],
undoAvailable: Boolean,
redoAvailable: Boolean,
)
@@ -0,0 +1,6 @@
package de.nowchess.api.dto
final case class GameStateEventDto(`type`: String, state: GameStateDto)
object GameStateEventDto:
def apply(state: GameStateDto): GameStateEventDto = GameStateEventDto("gameState", state)
@@ -0,0 +1,7 @@
package de.nowchess.api.dto
final case class ImportFenRequestDto(
fen: String,
white: Option[PlayerInfoDto],
black: Option[PlayerInfoDto],
)
@@ -0,0 +1,3 @@
package de.nowchess.api.dto
final case class ImportPgnRequestDto(pgn: String)
@@ -0,0 +1,9 @@
package de.nowchess.api.dto
final case class LegalMoveDto(
from: String,
to: String,
uci: String,
moveType: String,
promotion: Option[String],
)
@@ -0,0 +1,3 @@
package de.nowchess.api.dto
final case class LegalMovesResponseDto(moves: List[LegalMoveDto])
@@ -0,0 +1,3 @@
package de.nowchess.api.dto
final case class OkResponseDto(ok: Boolean = true)
@@ -0,0 +1,3 @@
package de.nowchess.api.dto
final case class PlayerInfoDto(id: String, displayName: String)