Showing
3 changed files
with
63 additions
and
0 deletions
package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
package.json
0 → 100644
1 | +{ | ||
2 | + "name": "coin-trade-assistant", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "test.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "repository": { | ||
10 | + "type": "git", | ||
11 | + "url": "http://khuhub.khu.ac.kr/2018102235/Coin-trade-assistant.git" | ||
12 | + }, | ||
13 | + "author": "", | ||
14 | + "license": "ISC", | ||
15 | + "dependencies": { | ||
16 | + "express": "^4.17.1", | ||
17 | + "node-fetch": "^2.6.1" | ||
18 | + } | ||
19 | +} |
test.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const app = express(); | ||
3 | + | ||
4 | +const fetch = require('node-fetch'); | ||
5 | +const api_key = '4h4PrjdPl04aplYHbM5xUK1xoGPffEfE';//Delete before commit API ddaro bonae jum. | ||
6 | + | ||
7 | +const url = 'https://api.whale-alert.io/v1/status?api_key=' + api_key; | ||
8 | +const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
9 | + | ||
10 | +fetch(url, options) | ||
11 | + .then(res => res.json()) | ||
12 | + .then(json => console.log(json)) | ||
13 | + .catch(err => console.error('error:' + err)); | ||
14 | + | ||
15 | + | ||
16 | +const url2 = 'https://api.whale-alert.io/v1/transactions?api_key=' + api_key; | ||
17 | + | ||
18 | +function data_collector(data){ | ||
19 | + var ret = ''; | ||
20 | + var str = ''; | ||
21 | + for(var i = 0; i < data.transactions.length; i++){ | ||
22 | + str = '#' + (i+1)+' ChainName: '+data.transactions[i].blockchain+'\tAmount: '+data.transactions[i].amount+' USD' | ||
23 | + if(data.transactions[i].amount > 1000000){ | ||
24 | + str = '=====!WARNING!=====\n</br>' + str + '\n</br>=====!WARNING!=====' | ||
25 | + console.log(str) | ||
26 | + } | ||
27 | + else{ | ||
28 | + console.log(str) | ||
29 | + } | ||
30 | + ret += '</br>' + str; | ||
31 | + } | ||
32 | + console.log(data.transactions) | ||
33 | + console.log(typeof(data.transactions)) | ||
34 | + return ret; | ||
35 | +} | ||
36 | + | ||
37 | +app.get('/', function (req, res) { | ||
38 | + fetch(url2, options) | ||
39 | + .then(res => res.json()) | ||
40 | + .then(json => res.send(data_collector(json))) | ||
41 | + .catch(err => console.error('error:' + err)); | ||
42 | +}) | ||
43 | + | ||
44 | +var server = app.listen(23023) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment