Advertisement
Guest User

app.get('/stats'

a guest
Dec 15th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. app.get('/stats',ensureAuthenticated, function(req, res){
  2. var token = req.get("Authorization")
  3. , decoded = jwt.verify(token, secret)
  4. , steamId = decoded.steamid;
  5.  
  6. if(admins.indexOf(steamId) > -1){
  7. Mongo.query("jackpots", {"status": "presented"}, function(jackpotResult){
  8. var jackpotEarnings = 0;
  9.  
  10. for (var i = 0; i < jackpotResult.length; i++) {
  11. jackpotEarnings = jackpotEarnings + (jackpotResult[i].totalAmountBeforeFee - jackpotResult[i].winnerAmount);
  12. }
  13.  
  14. res.json({"successfull": true, "jackpot": jackpotEarnings});
  15. res.end();
  16. });
  17. }else{
  18. res.json({"successfull": false});
  19. res.end();
  20. }
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement