|
|
@ -34,6 +34,7 @@ function queryGitHubAPI(requestURL) |
|
|
|
{ |
|
|
|
queryURL = GITHUB_API + requestURL + "?" + authenticate; |
|
|
|
} |
|
|
|
console.log(queryURL); |
|
|
|
|
|
|
|
got(queryURL, { json: true }).then(response => |
|
|
|
{ |
|
|
@ -41,12 +42,9 @@ function queryGitHubAPI(requestURL) |
|
|
|
cache.put(requestURL, response.body); |
|
|
|
}).catch(error => |
|
|
|
{ |
|
|
|
// resolve(response.body);
|
|
|
|
// cache.put(requestURL, response.body);
|
|
|
|
console.log(error); |
|
|
|
reject(error); |
|
|
|
cache.put(requestURL, response.body); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -60,24 +58,20 @@ routes.get('/*', (request, result) => |
|
|
|
{ |
|
|
|
var gitHubAPIURL = request.url; |
|
|
|
|
|
|
|
// if(request.query.hasOwnProperty("page"))
|
|
|
|
// {
|
|
|
|
// gitHubAPIURL += "?page=" + request.query.page;
|
|
|
|
// }
|
|
|
|
|
|
|
|
console.log(request.query); |
|
|
|
|
|
|
|
console.log(gitHubAPIURL); |
|
|
|
|
|
|
|
|
|
|
|
result.setHeader('Content-Type', 'application/json'); |
|
|
|
queryGitHubAPI(gitHubAPIURL).then(function(data) |
|
|
|
{ |
|
|
|
result.write(JSON.stringify(data)); |
|
|
|
if(data.hasOwnProperty("id")) |
|
|
|
{ |
|
|
|
result.write(JSON.stringify(data)); |
|
|
|
} |
|
|
|
result.end(); |
|
|
|
}).catch(function(error) |
|
|
|
{ |
|
|
|
result.write(JSON.stringify(error)); |
|
|
|
if(error.hasOwnProperty("id")) |
|
|
|
{ |
|
|
|
result.write(JSON.stringify(error)); |
|
|
|
} |
|
|
|
result.end(); |
|
|
|
}) |
|
|
|
}); |
|
|
|