-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi_server.ts
More file actions
101 lines (74 loc) · 3.78 KB
/
api_server.ts
File metadata and controls
101 lines (74 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Algodex Service
* Copyright (C) 2022 Algodex VASP (BVI) Corp.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { logRemote, serveGetLogs } from "./log_remote";
import { getAlgoAndAsaTVLByAsset, getV2OrdersByAssetId, serveGetHiddenOrders, serveGetOrdersByAssetId, serveGetOrdersByWallet, serveGetTVL, serveGetTVL2 } from "./orders";
import { serveCouchProxy } from "./proxy";
import { isAccruingRewards,
get_rewards_per_epoch, save_rewards, serveIsOptedIn, serveGetRewardsDistribution, serveGetLeaderboard, serveRewardsIsRecorded, serveRewardsData, serveVestedRewardsData, serveUnrecordedRewards } from "./rewards";
import { serveCharts, serveTradeHistoryByAssetId, serveTradeHistoryByOwner, serveChartsNoCache, serveCachedAssetPrices, serveAllAssetPrices, serveSearch, serveSearchAll } from "./trade_history";
import { serve_auth_check } from "./util";
import { serveGetWalletAssets } from "./wallet";
const nocache = require("nocache");
/* eslint-disable @typescript-eslint/no-var-requires */
require('dotenv').config();
const express = require('express')
const app = express()
app.use(express.json({limit: '50mb'}));
app.use(express.urlencoded({limit: '50mb'}));
app.enable('etag'); // should be enabled by default anyways
app.use(nocache());
const port = 3006
// Orders
app.get('/asset/hidden/:assetId', serveGetHiddenOrders);
app.get('/orders/asset/:assetId', serveGetOrdersByAssetId);
app.get('/orders/wallet/:ownerAddress', serveGetOrdersByWallet);
app.get('/orders/tvl', serveGetTVL);
app.get('/orders/tvl2', serveGetTVL2);
// Assets
app.get('/assets/all', serveCachedAssetPrices);
app.get('/assets/search/:searchStr', serveSearch);
app.get('/assets/searchall', serveSearchAll);
app.get('/assets/:assetId', serveCachedAssetPrices);
// app.get('/assets/all/nocache', serveAllAssetPrices);
// Trade History
app.get('/trades/history/asset/:assetId', serveTradeHistoryByAssetId);
app.get('/trades/history/wallet/:ownerAddress', serveTradeHistoryByOwner);
// Charts
app.get('/trades/charts/asset/:assetId/period/:period', serveCharts);
//app.get('/trades/charts/asset/:assetId/period/:period/nocache', serveChartsNoCache);
// Wallet
app.get('/wallet/assets/:ownerAddress', serveGetWalletAssets);
// Proxy
app.post('/query/:database/_design/:index/_view/:view', serveCouchProxy);
// Rewards
app.post('/save_rewards', save_rewards);
// curl -v -H 'couch-password: <password>' -X POST http://localhost:3006/auth_check
app.post('/auth_check', serve_auth_check);
app.get('/rewards/per_epoch/wallet/:wallet', get_rewards_per_epoch);
app.get('/rewards/is_accruing/:wallet', isAccruingRewards);
app.get('/rewards/unrecorded', serveUnrecordedRewards);
app.get('/wallets/leaderboard', serveGetLeaderboard);
app.get('/rewards/optin/:wallet', serveIsOptedIn);
app.get('/rewards_distribution', serveGetRewardsDistribution);
app.get('/rewards/is_recorded/period/:epoch', serveRewardsIsRecorded);
app.get('/rewards/accumulated/wallet/:wallet', serveRewardsData);
app.get('/rewards/vested/wallet/:wallet', serveVestedRewardsData);
// Logging
app.post('/debug/log/post', logRemote);
app.get('/debug/log/get', serveGetLogs);
app.listen(port, () => {
console.log(`Algodex Service listening on port ${port}`)
})
export {};