app.get('/play/:cell/:color', (req, res) => { // TODO: security let cell = req.params['cell']; let color = req.params['color']; if (color != game.state.next) { res.status(403).send("Not your turn, my friend!"); return; } if (game.grid[cell] != " ") { res.status(403).send("Cell is not free, buddy!"); return; } if (game['player_' + color] != getUserId(req, res)) { res.status(403).send("Trying to play for someone else?!"); return; } game.grid[cell] = color; if (game.state.next == 'X') { game.state.next = 'O'; } else { game.state.next = 'X'; } sendGame(req, res); });