Skip to content

Commit

Permalink
Merge pull request #258 from BackendsByMTT/dev-g
Browse files Browse the repository at this point in the history
 Updated response for bets
  • Loading branch information
TrippyRahul authored Oct 17, 2024
2 parents 11fac34 + d7fd326 commit e7000c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/bets/betController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class BetController {
)}`,
})
);
res.status(200).json({ message: "Bet Redeemed Successfully" });
res.status(200).json({ message: "Bet Redeemed Successfully" , data:bet});
if (playerSocket) {
playerSocket.sendData({ type: "CREDITS", credits: player.credits });
}
Expand Down Expand Up @@ -793,7 +793,7 @@ async resolveBet(req: Request, res: Response, next: NextFunction) {
playerSocket.sendData({ type: "CREDITS", credits: player.credits });
}

return res.status(200).json({ message: "Bet detail updated and amount deducted" });
return res.status(200).json({ message: "Bet detail updated and amount deducted" , data:parentBet});
}

if (!hasNotWon && parentBet.status !== "won") {
Expand Down Expand Up @@ -825,7 +825,7 @@ async resolveBet(req: Request, res: Response, next: NextFunction) {
removeFromWaitingQueue(JSON.stringify(data));
});

return res.status(200).json({ message: "Bet detail status updated" });
return res.status(200).json({ message: "Bet detail status updated", data:updatedBetDetails });
} catch (error) {
console.log(error);

Expand Down Expand Up @@ -992,7 +992,7 @@ async resolveBet(req: Request, res: Response, next: NextFunction) {
agentMessage: agentResponseMessage,
})
);
res.status(200).json({ message: "Bet and BetDetails updated successfully", updatedBet });
res.status(200).json({ message: "Bet and BetDetails updated successfully", data:updatedBet });
} catch (error) {
console.log(error);

Expand Down
7 changes: 5 additions & 2 deletions src/transactions/transactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TransactionController {
throw createHttpError(500, "Unknown reciever model");
})();

const transaction = await TransactionService.performTransaction(
await TransactionService.performTransaction(
newObjectId,
receiverId,
sender,
Expand All @@ -69,7 +69,10 @@ class TransactionController {
sanitizedAmount,
role
);
res.status(200).json({ message: "Transaction successful" , data:transaction});
const updatedRecieverData = (await User.findById({ _id: receiverId })) ||
(await Player.findById({ _id: receiverId }))

res.status(200).json({ message: "Transaction successful" , data:updatedRecieverData});
} catch (err) {
console.log(err);

Expand Down
4 changes: 2 additions & 2 deletions src/users/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class UserController {
(await Player.findOne({ username: sanitizedUsername }));

if (!user) {
throw createHttpError(401, "User not found");
throw createHttpError(401, "Username or password is incorrect");
}

const userStatus = user.status === "inactive";
Expand All @@ -106,7 +106,7 @@ class UserController {
user.password
);
if (!isPasswordValid) {
throw createHttpError(401, "Incoreect password");
throw createHttpError(401, "Username or password is incorrect");
}

user.lastLogin = new Date();
Expand Down

0 comments on commit e7000c6

Please sign in to comment.