diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-06-14 20:39:02 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-06-14 20:48:48 +0200 |
commit | ae02f4cde98879b6fddc12c87c4fd3c5663d493e (patch) | |
tree | 157c5f74d0d69c7485232edd38876e04785d94c4 /server.js | |
parent | 64608341e200cceb92a6cb3e523e0863b2c04ccd (diff) | |
download | server-ae02f4cde98879b6fddc12c87c4fd3c5663d493e.tar.gz |
Add debug mode for super-user.
Like replay but for live games.
Shows available actions.
Doesn't remove undo actions.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -1513,6 +1513,19 @@ app.get('/:title_id/replay\::game_id', function (req, res) { return res.sendFile(__dirname + '/public/' + title_id + '/play.html') }) +app.get('/:title_id/debug\::game_id', function (req, res) { + if (!req.user || req.user.user_id !== 1) + return res.status(401).send("Not authorized to debug.") + let title_id = req.params.title_id + let game_id = req.params.game_id + let game = SQL_SELECT_GAME.get(game_id) + if (!game) + return res.status(404).send("Invalid game ID.") + if (game.title_id !== title_id) + return res.status(404).send("Invalid game ID.") + return res.sendFile(__dirname + '/public/' + title_id + '/play.html') +}) + app.get('/replay/:game_id', function (req, res) { let game_id = req.params.game_id let game = SQL_SELECT_GAME.get(game_id) @@ -1524,6 +1537,16 @@ app.get('/replay/:game_id', function (req, res) { return res.json({players, state, replay}) }) +app.get('/debug/:game_id', function (req, res) { + if (!req.user || req.user.user_id !== 1) + return res.status(401).send("Not authorized to debug.") + let game_id = req.params.game_id + let players = SQL_SELECT_PLAYERS_JOIN.all(game_id) + let state = SQL_SELECT_GAME_STATE.get(game_id) + let replay = SQL_SELECT_REPLAY.all(game_id) + return res.json({players, state, replay}) +}) + /* * MAIL NOTIFICATIONS */ |