Showing
1 changed file
with
10 additions
and
71 deletions
1 | -module.exports = function(app){ | 1 | +var user=require("../user/userinfo") |
2 | - | 2 | +var express = require('express'); |
3 | -var request = require("request"); | 3 | +var app = express.Router(); |
4 | -var urlenconde = require('urlencode'); | 4 | +app.get('/', function(req, res) { |
5 | -var apikey = "RGAPI-4ccc267c-4dba-46f4-b705-bdb224f15ac2"//api | ||
6 | -var my_grade | ||
7 | -var profileIconId; //아이콘 번호 | ||
8 | -var revisionDate; //수정날짜 | ||
9 | -var id; //소환사ID | ||
10 | -var accountId; //계정Id | ||
11 | -var name; //소환사 이름 | ||
12 | -var summonerLevel; //소환사 레벨 | ||
13 | -var puuid; //소환서 puuid | ||
14 | -var startIndex; | ||
15 | -var endIndex; | ||
16 | -var totalGames; | ||
17 | -var matches=[]; //경기정보 | ||
18 | -var game_name; | ||
19 | - app.get('/', function(req, res) { | ||
20 | res.render('main', { title: 'R U TROLL?' }); | 5 | res.render('main', { title: 'R U TROLL?' }); |
21 | - }); | 6 | +}); |
22 | - | ||
23 | - app.get('/search/:username/', function(req, res){ | ||
24 | - //롤 api url | ||
25 | - name = req.params.username; | ||
26 | - var nameUrl = "https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + urlenconde(name)+"?api_key="+ apikey; | ||
27 | - request(nameUrl,function(error,response,body){ | ||
28 | - var info_summoner_json = JSON.parse(body); | ||
29 | - accountId = info_summoner_json["accountId"]; | ||
30 | - id = info_summoner_json["id"]; | ||
31 | - summoner = info_summoner_json["name"]; | ||
32 | - profileIconId = info_summoner_json["profileIconId"]; | ||
33 | - summonerLevel = info_summoner_json["summonerLevel"]; | ||
34 | - revisionDate = info_summoner_json["revisionDate"]; | ||
35 | - puuid=info_summoner_json["puuid"] | ||
36 | - var option={ | ||
37 | - url:"https://asia.api.riotgames.com/tft/match/v1/matches/by-puuid/"+puuid+"/ids?count=20", | ||
38 | - headers:{ | ||
39 | - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36", | ||
40 | - "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | ||
41 | - "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
42 | - "Origin": "https://developer.riotgames.com", | ||
43 | - "X-Riot-Token": apikey | ||
44 | - } | ||
45 | - } | ||
46 | - request(option,function(error,response,body){ | ||
47 | - var temp_game_name = JSON.parse(body); | ||
48 | - game_name=temp_game_name | ||
49 | - console.log(game_name) | ||
50 | - for (i=0;i<19;i++) | ||
51 | - { | ||
52 | - var game_url="https://asia.api.riotgames.com/tft/match/v1/matches/"+game_name[i]+"?api_key="+apikey | ||
53 | - | ||
54 | - request(game_url,function(error,response,body){ | ||
55 | - | ||
56 | - var temp_game_trait = JSON.parse(body); | ||
57 | - console.log(temp_game_trait) | ||
58 | - var grade=temp_game_trait["info"]["participants"] | ||
59 | - for (j=0;j<8;j++) | ||
60 | - { | ||
61 | - if(grade[j]["puuid"]==puuid && grade[j]["placement"]>=4) | ||
62 | - { | ||
63 | - matches.push(temp_game_trait["info"]["game_variation"]) | ||
64 | - } | ||
65 | - } | ||
66 | - | ||
67 | - }); | ||
68 | - | ||
69 | - } | ||
70 | 7 | ||
71 | - }); | 8 | +app.get('/search/:username/', function(req, res){ |
72 | - }); | 9 | + var name=req.params.username |
10 | + user.userInfo(name) | ||
73 | }); | 11 | }); |
74 | -} | 12 | + |
13 | +module.exports=app; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment