/** All games by gameid. */ let games = {} app.get('/:gameid/game', (req, res) => { const gameid = parseInt(req.params['gameid']) let game = games[gameid] if (game == undefined) { // Create a new game if it does not exist. game = newGame(gameid) games[gameid] = game } res.json(game) }) app.get('/:gameid/set/:column', (req, res) => { const game = games[parseInt(req.params['gameid'])] if (game == undefined) { // Send error code res.status(404).json("no such game") } else { let column = parseInt(req.params['column']) dropPiece(game, column) res.json(game) } })