Create route to list all the games

This commit is contained in:
2025-04-14 23:39:52 +02:00
parent 8074881d57
commit c3155da23c
14 changed files with 304 additions and 18 deletions
@@ -0,0 +1,28 @@
package eventDemo.adapter.interfaceLayer
import eventDemo.business.event.projection.gameList.GameListRepository
import io.ktor.resources.Resource
import io.ktor.server.application.call
import io.ktor.server.auth.authenticate
import io.ktor.server.resources.get
import io.ktor.server.response.respond
import io.ktor.server.routing.Route
import io.ktor.server.routing.get
import kotlinx.serialization.Serializable
@Serializable
@Resource("/games")
class Games
/**
* API routes to show all games.
*/
fun Route.readGamesList(gameListRepository: GameListRepository) {
authenticate {
// Read the last played card on the game.
get<Games> {
val gameList = gameListRepository.getList()
call.respond(gameList)
}
}
}
@@ -13,7 +13,7 @@ import io.ktor.server.routing.Route
import kotlinx.serialization.Serializable
@Serializable
@Resource("/game/{id}")
@Resource("/games/{id}")
class Game(
@Serializable(with = GameIdSerializer::class)
val id: GameId,