Let's imagine a scenario where I have a table called gameData {gameId, currentBoardLayout}. A GET request is sent to the server at www.chess.com/asd123, with "asd123" being the game id. In order to handle this situation, I will need to extract this id (asd123) and search for it in my table (gameData). Once found, the following logic should be implemented:
srv.get('/:id', (req, res) => {
if ( gameData.findAll({where: {gameId: req.params.id} )
{ // Game room found
return currentBoardLayout
}
else
{ error : Invalid game id }
})
Can anyone guide me on how to go about achieving this? Thanks!