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.get('/get_pinnacle_balance', (req, res) => { const { channel } = req.query; Games.getPinnacleAccountBalance({ channel }) .then(balance => { res.sendSuccess(balance); }) .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;