| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import express from 'express';
- const router = express.Router();
- import Games from '../models/Games.js';
- router.get('/get_leagues', (req, res) => {
- Games.getLeagues()
- .then(leagues => {
- res.sendSuccess(leagues);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.post('/set_leagues_relation', (req, res) => {
- Games.setLeaguesRelation(req.body)
- .then(() => {
- res.sendSuccess();
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.post('/remove_leagues_relation', (req, res) => {
- const { id } = req.body;
- Games.removeLeaguesRelation(id)
- .then(() => {
- res.sendSuccess();
- }).catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_leagues_relations', (req, res) => {
- Games.getLeaguesRelations()
- .then(relations => {
- res.sendSuccess(relations);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_games', (req, res) => {
- Games.getGames()
- .then(games => {
- res.sendSuccess(games);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.post('/set_relation', (req, res) => {
- Games.setGamesRelation(req.body)
- .then(() => {
- res.sendSuccess();
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.post('/remove_relation', (req, res) => {
- const { id } = req.body;
- Games.removeGamesRelation(id)
- .then(() => {
- res.sendSuccess();
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_relations', (req, res) => {
- Games.getGamesRelations()
- .then(relations => {
- res.sendSuccess(relations);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_solutions', (req, res) => {
- const { min_profit_rate } = req.query;
- Games.getSolutions({ min_profit_rate })
- .then(solutions => {
- res.sendSuccess(solutions);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_solution_ior_info', (req, res) => {
- const { sid } = req.query;
- Games.getSolutionIorsInfo(sid)
- .then(iorInfo => {
- res.sendSuccess(iorInfo);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/bet_solution', (req, res) => {
- const { sid, stake } = req.query;
- Games.betSolution(sid, stake)
- .then(betInfo => {
- res.sendSuccess(betInfo);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/orders', (req, res) => {
- const { limit } = req.query;
- Games.getOrders({ limit })
- .then(orders => {
- res.sendSuccess(orders);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.delete('/orders/:id', (req, res) => {
- const { id } = req.params;
- Games.removeOrder(id)
- .then(order => {
- res.sendSuccess(order);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_polymarket_orders/open', (req, res) => {
- const {
- id,
- market,
- asset_id,
- assetId,
- only_first_page,
- next_cursor,
- } = req.query;
- Games.getOpenOrders({
- id,
- market,
- asset_id: asset_id || assetId,
- only_first_page: only_first_page === true || only_first_page === 'true',
- next_cursor,
- })
- .then(orders => {
- res.sendSuccess(orders);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_polymarket_order/:orderID', (req, res) => {
- const { orderID } = req.params;
- Games.getOrder({ orderID })
- .then(order => {
- res.sendSuccess(order);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.get('/get_polymarket_balance_allowance/:wallet', (req, res) => {
- const { wallet } = req.params;
- Games.getPolymarketBalanceAllowance({ wallet })
- .then(balanceAllowance => {
- res.sendSuccess(balanceAllowance);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- router.post('/transfer_polymarket_wallet', (req, res) => {
- const { amount, from, to } = req.body;
- Games.transferPolymarketWallet({ amount, from, to })
- .then(result => {
- res.sendSuccess(result);
- })
- .catch(err => {
- res.sendError(err);
- });
- });
- export default router;
|