Toggle navigation
Toggle navigation
This project
Loading...
Sign in
허연우
/
FindMe.GG
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
LIANG XIAOTONG
2022-11-25 00:12:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b57accdd631076c39c5612307c6762faa3d391da
b57accdd
1 parent
c216e915
Only interface
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
RUTROLL/router/main(1).js
RUTROLL/router/main(1).js
0 → 100644
View file @
b57accd
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
request
=
require
(
"request"
);
const
urlenconde
=
require
(
'urlencode'
);
const
apikey
=
"RGAPI-816bb9a0-615c-41e0-a01e-f5e0bb68c3a6"
//api
router
.
get
(
'/search/summoner/:username/'
,
function
(
req
,
res
)
{
//롤 api url
const
name
=
req
.
params
.
username
;
var
nameUrl
=
"https://kr.api.riotgames.com/tft/summoner/v1/summoners/by-name/"
+
urlenconde
(
name
)
+
"?api_key="
+
apikey
;
request
(
nameUrl
,
function
(
error
,
response
,
body
)
{
var
info_summoner_json
=
JSON
.
parse
(
body
);
const
summonerId
=
info_summoner_json
.
id
;
const
rankUrl
=
`https://kr.api.riotgames.com/tft/league/v1/entries/by-summoner/
${
urlenconde
(
summonerId
)}
?api_key=
${
apikey
}
`
;
request
(
rankUrl
,
function
(
error
,
response
,
body
)
{
const
rank_info
=
JSON
.
parse
(
body
);
res
.
json
({
status
:
200
,
data
:
{
summoner
:
info_summoner_json
,
leagueList
:
rank_info
}
});
});
});
});
router
.
get
(
'/search/match/:puuid'
,
function
(
req
,
res
)
{
//api url
const
puuid
=
req
.
params
.
puuid
;
const
matchIdUrl
=
`https://asia.api.riotgames.com/tft/match/v1/matches/by-puuid/
${
puuid
}
/ids?api_key=
${
apikey
}
`
;
request
(
matchIdUrl
,
function
(
error
,
response
,
body
)
{
const
matchIdList
=
JSON
.
parse
(
body
);
const
promiseList
=
[];
matchIdList
.
forEach
(
matchId
=>
{
promiseList
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
const
matchURL
=
`https://asia.api.riotgames.com/tft/match/v1/matches/
${
matchId
}
?api_key=
${
apikey
}
`
;
request
(
matchURL
,
function
(
error
,
response
,
body
)
{
const
match
=
JSON
.
parse
(
body
);
resolve
(
match
);
});
}));
Promise
.
all
(
promiseList
).
then
(
matches
=>
{
res
.
json
({
status
:
200
,
data
:
{
matchList
:
matches
}
});
})
});
});
module
.
exports
=
router
;
\ No newline at end of file
Please
register
or
login
to post a comment