Advertisement
Guest User

stats

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