import { CommonMancalaGame, MancalaGame } from "mancala.js"; import { HttpService } from "../service/HttpService"; export interface GameStore { get(id: string): Promise; } export class GameStoreImpl implements GameStore { httpService: HttpService; constructor(props: { httpService: HttpService }) { this.httpService = props.httpService; } async get(id: string): Promise { try { const response = await this.httpService.get(`/game/${id}`); const json = await response.json(); return MancalaGame.createFromMancalaGame(json as CommonMancalaGame); } catch (error) { // todo check error Promise.resolve(undefined); } } }