node-mongo-demo

node.js and mongodb demo

git clone https://9o.is/git/node-mongo-demo.git

commit daa3bf469a227af3d79ecdebb271c95c932af35f
parent 9f4cee8b11410a10d619fc4ec0af17da6a5a2772
Author: Jul <jul@9o.is>
Date:   Mon, 27 Jan 2025 05:55:14 -0500

return pending results when creating bet

Diffstat:
Mbackend/src/api/lucky7-bets-create.js | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/backend/src/api/lucky7-bets-create.js b/backend/src/api/lucky7-bets-create.js @@ -21,7 +21,7 @@ const lucky7BetsCreate = async (req, res) => { const session = await lucky7Session(userId); if (session.nextGameInSeconds <= 5) { - return res.status(400).json({ message: '5 seconds or less remaining for next dice roll' }) + return res.status(400).json({ code: "TIMER", message: '5 seconds or less remaining for next dice roll' }) } const rollAt = nextGameTime(session.createdAt); @@ -42,7 +42,11 @@ const lucky7BetsCreate = async (req, res) => { bet.win = outcome(bet.roll, lucky); await bet.save() - res.status(200).json(bet); + res.status(200).json({ + id: bet._id, + lucky: bet.lucky, + rollAt: bet.rollAt, + }); } catch (error) { console.error(error); res.status(500).json({ message: "Something went wrong" });