games.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import express from 'express';
  2. const router = express.Router();
  3. import Games from '../models/Games.js';
  4. router.get('/get_leagues', (req, res) => {
  5. Games.getLeagues()
  6. .then(leagues => {
  7. res.sendSuccess(leagues);
  8. })
  9. .catch(err => {
  10. res.sendError(err);
  11. });
  12. });
  13. router.post('/set_leagues_relation', (req, res) => {
  14. Games.setLeaguesRelation(req.body)
  15. .then(() => {
  16. res.sendSuccess();
  17. })
  18. .catch(err => {
  19. res.sendError(err);
  20. });
  21. });
  22. router.post('/remove_leagues_relation', (req, res) => {
  23. const { id } = req.body;
  24. Games.removeLeaguesRelation(id)
  25. .then(() => {
  26. res.sendSuccess();
  27. }).catch(err => {
  28. res.sendError(err);
  29. });
  30. });
  31. router.get('/get_leagues_relations', (req, res) => {
  32. Games.getLeaguesRelations()
  33. .then(relations => {
  34. res.sendSuccess(relations);
  35. })
  36. .catch(err => {
  37. res.sendError(err);
  38. });
  39. });
  40. router.get('/get_games', (req, res) => {
  41. Games.getGames()
  42. .then(games => {
  43. res.sendSuccess(games);
  44. })
  45. .catch(err => {
  46. res.sendError(err);
  47. });
  48. });
  49. router.post('/set_relation', (req, res) => {
  50. Games.setGamesRelation(req.body)
  51. .then(() => {
  52. res.sendSuccess();
  53. })
  54. .catch(err => {
  55. res.sendError(err);
  56. });
  57. });
  58. router.post('/remove_relation', (req, res) => {
  59. const { id } = req.body;
  60. Games.removeGamesRelation(id)
  61. .then(() => {
  62. res.sendSuccess();
  63. })
  64. .catch(err => {
  65. res.sendError(err);
  66. });
  67. });
  68. router.get('/get_relations', (req, res) => {
  69. Games.getGamesRelations()
  70. .then(relations => {
  71. res.sendSuccess(relations);
  72. })
  73. .catch(err => {
  74. res.sendError(err);
  75. });
  76. });
  77. router.get('/get_solutions', (req, res) => {
  78. const { min_profit_rate } = req.query;
  79. Games.getSolutions({ min_profit_rate })
  80. .then(solutions => {
  81. res.sendSuccess(solutions);
  82. })
  83. .catch(err => {
  84. res.sendError(err);
  85. });
  86. });
  87. router.get('/get_solution_ior_info', (req, res) => {
  88. const { sid } = req.query;
  89. Games.getSolutionIorsInfo(sid)
  90. .then(iorInfo => {
  91. res.sendSuccess(iorInfo);
  92. })
  93. .catch(err => {
  94. res.sendError(err);
  95. });
  96. });
  97. router.get('/bet_solution', (req, res) => {
  98. const { sid, stake } = req.query;
  99. Games.betSolution(sid, stake)
  100. .then(betInfo => {
  101. res.sendSuccess(betInfo);
  102. })
  103. .catch(err => {
  104. res.sendError(err);
  105. });
  106. });
  107. export default router;