Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정홍주
/
Coin-trade-assistant
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
배지승
2021-06-06 02:25:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c4e923e160c5772afd8f1f2acc45ea689e0930de
c4e923e1
1 parent
0a17261c
거래 시간 표시 추가
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
30 deletions
app.js
timestamp
app.js
View file @
c4e923e
const
express
=
require
(
'express'
);
const
app
=
express
();
const
fetch
=
require
(
'node-fetch'
);
const
fs
=
require
(
'fs'
);
const
api_key
=
fs
.
readFileSync
(
'apikey'
,
'ascii'
)
console
.
log
(
'apikey:'
,
api_key
)
//const url = 'https://api.whale-alert.io/v1/status?api_key=' + api_key
const
options
=
{
method
:
'GET'
,
headers
:
{
Accept
:
'application/json'
}};
const
fs_apikey
=
require
(
'fs'
);
const
api_key
=
fs_apikey
.
readFileSync
(
'apikey'
,
'ascii'
)
var
cursor
=
''
url2
=
'https://api.whale-alert.io/v1/transactions?api_key='
+
api_key
+
'&limit=1&cursor='
+
cursor
;
//Initialize timestamp
url2
=
'https://api.whale-alert.io/v1/transactions?api_key='
+
api_key
+
'&cursor='
+
cursor
;
const
options
=
{
method
:
'GET'
,
headers
:
{
Accept
:
'application/json'
}};
const
fs2
=
require
(
'fs'
)
const
fs3
=
require
(
'fs'
)
//Initialize cursor
var
TimeNow
=
parseInt
((
new
Date
()).
getTime
()
/
1000
)
var
uts2time
=
new
Date
()
console
.
log
(
TimeNow
)
console
.
log
(
'파일쓰기'
)
fetch
(
url2
,
options
)
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
console
.
log
(
json
)
fs2
.
writeFileSync
(
'timestamp'
,
json
.
cursor
,
'ascii'
)
cursor
=
json
.
cursor
})
.
catch
((
err
)
=>
{
console
.
log
(
'error : inital_fetch:'
+
err
)
})
// fetch(url, options)
// .then(res => res.json())
// .then(json => console.log(json))
// .catch(err => console.error('error:' + err));
function
chk_param
(
data
,
query_limit
,
callback
){
//query_limit (non_int) => return 0;
...
...
@@ -43,8 +33,10 @@ function data_collector(data, limit){
var
ret
=
''
;
var
str
=
''
;
ret
+=
'# of Transactions : '
+
data
.
count
+
'\n'
for
(
var
i
=
0
;
i
<
data
.
count
;
i
++
){
str
=
'#'
+
(
i
+
1
)
+
' ChainName: '
+
data
.
transactions
[
i
].
blockchain
+
'\tAmount: '
+
data
.
transactions
[
i
].
amount
+
' USD'
uts2time
.
setTime
(
data
.
transactions
[
i
].
timestamp
*
1000
)
str
=
'#'
+
(
i
+
1
)
+
' \tTime: '
+
uts2time
.
toLocaleString
()
+
'\tChainName: '
+
data
.
transactions
[
i
].
blockchain
+
'\tAmount: '
+
data
.
transactions
[
i
].
amount
+
' USD'
if
(
data
.
transactions
[
i
].
amount
>
limit
){
//console.log(str)
ret
+=
'</br>'
+
str
;
...
...
@@ -55,24 +47,24 @@ function data_collector(data, limit){
}
return
ret
;
}
app
.
get
(
'/'
,
function
(
req
,
res
)
{
cursor
=
fs3
.
readFileSync
(
'timestamp'
,
'ascii'
)
console
.
log
(
'cursor'
,
url2
)
app
.
get
(
'/whale'
,
function
(
req
,
res
)
{
console
.
log
(
'cursor'
,
cursor
)
fu
=
fetch
(
url2
+
cursor
,
options
);
fu
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
//API usage limit
console
.
log
(
json
)
if
(
json
.
result
==
'error'
){
res
.
send
(
"Please try later"
)
}
else
{
fs2
.
writeFileSync
(
'timestamp'
,
json
.
cursor
,
'ascii'
)
cursor
=
json
.
cursor
res
.
send
(
chk_param
(
json
,
req
.
query
.
limit
,
data_collector
))
}
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
))
.
catch
(
err
=>
{
console
.
error
(
'error: var:fu:'
+
err
)
res
.
send
(
'ERROR'
)
})
})
var
server
=
app
.
listen
(
23023
)
\ No newline at end of file
...
...
timestamp
deleted
100644 → 0
View file @
0a17261
6084feb2-6084feb2-60ba4692
\ No newline at end of file
Please
register
or
login
to post a comment