Browse Source

Merge branch 'master' of github.com:jrtechs/github-graphs

pull/11/head
Bryce Murphy 5 years ago
parent
commit
2fa0232e4a
1 changed files with 24 additions and 28 deletions
  1. +24
    -28
      routes/api.js

+ 24
- 28
routes/api.js View File

@ -13,43 +13,39 @@ const authenticate = "?client_id=" + configLoader.getClientID() +
"&client_secret=" + configLoader.getClientSecret();
//caching program to make the application run faster
const cache = require('memory-cache');
function queryGitHubAPI(requestURL)
{
const apiData = cache.get(requestURL);
return new Promise(function(reject, resolve)
{
const queryRUL = GITHUB_API + requestURL + authenticate;
got(queryRUL, { json: true }).then(response =>
if(apiData == null)
{
resolve(response.body);
}).catch(error =>
const queryRUL = GITHUB_API + requestURL + authenticate;
got(queryRUL, { json: true }).then(response =>
{
resolve(response.body);
cache.put(requestURL, response.body);
}).catch(error =>
{
resolve(response.body);
cache.put(requestURL, response.body);
});
}
else
{
resolve(response.body)
});
resolve(apiData);
}
})
}
//https://api.github.com/users/whatever?client_id=xxxx&client_secret=yyyy
// function authenticateWithGitHub()
// {
// const authURL = GITHUB_API + "/users/" + configLoader.getAPIUser() + "?client_id=" + configLoader.getClientID() +
// "&client_secret=" + configLoader.getClientSecret();
//
// return new Promise(function(resolve, reject)
// {
// got(authURL, { json: true }).then(response =>
// {
// console.log(response);
// resolve(response);
// }).catch(error => {
// reject(error);
// console.log(error.response.body);
// });
// })
//
// }
routes.get('/*', (request, result) =>

Loading…
Cancel
Save