diff --git a/site/package.json b/site/package.json index 686e12f3..02fbfd0a 100644 --- a/site/package.json +++ b/site/package.json @@ -18,6 +18,10 @@ "devtest" ], "dependencies": { + "@babel/core": "^7.13.10", + "@babel/preset-env": "^7.13.10", + "@babel/preset-react": "^7.12.13", + "@babel/register": "^7.13.8", "async": "^1.0.0", "body-parser": "^1.6.4", "classnames": "^2.1.3", @@ -42,10 +46,6 @@ "superagent": "^3.8.3" }, "devDependencies": { - "@babel/core": "^7.13.10", - "@babel/preset-env": "^7.13.10", - "@babel/preset-react": "^7.12.13", - "@babel/register": "^7.13.8", "babel-eslint": "^10.0.0", "babel-loader": "^8.2.2", "chai": "^3.0.0", diff --git a/site/secrets.js b/site/secrets.js index ba87ac72..8599b0a1 100644 --- a/site/secrets.js +++ b/site/secrets.js @@ -1,17 +1,11 @@ /** - * This is a sample file for your Github client id and client secret - * This is needed to collect the doc's from the fluxible repo. - * You can generate the client/secret pair here: https://github.com/settings/applications/new + * This is a sample file for using your Github access token to collect + * the doc's from the fluxible repo. * - * Alternatively, you can pass in an oauth access token to work around the rate limiting - * restrictions of the client id / secret pair - * - * GitHub Auth docs: https://developer.github.com/v3/#authentication + * GitHub Auth docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#authentication */ export default { github: { - accessToken: process.env.GITHUB_ACCESS_TOKEN || '', - clientId: process.env.GITHUB_CLIENT_ID || '', - clientSecret: process.env.GITHUB_CLIENT_SECRET || '' + accessToken: process.env.GITHUB_ACCESS_TOKEN || '' } }; diff --git a/site/services/docs.js b/site/services/docs.js index 9331d7e6..b1f7ad1e 100644 --- a/site/services/docs.js +++ b/site/services/docs.js @@ -26,6 +26,12 @@ marked.setOptions({ } }); +if (secrets.github.accessToken) { + console.log('All good! Found access token.'); +} else { + console.error('Not good! Missing access token. Will be rate-limited by github API.'); +} + // Generate a hash of valid api routes, from the /configs/apis.js file let cache = {}; let documents = {}; @@ -58,22 +64,6 @@ function fetchGitHubReposApi(params, cb) { // create github api url let githubUrl = 'https://api.github.com/repos/' + repo + '/' + type + '?'; - // use access token if available, otherwise use client id and secret - if (secrets.github.accessToken) { - // using accessToken as query param is being deprecated - // https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ - // githubUrl += qs.stringify({ - // access_token: secrets.github.accessToken - // }); - } else { - // using clientId and clientSecret as query param is being deprecated as well. - // will remove this after switching fluxible.io to use accessToken. - githubUrl += qs.stringify({ - client_id: secrets.github.clientId, - client_secret: secrets.github.clientSecret - }); - } - // the name of the commit/branch/tag if (params.ref) { githubUrl += '&ref=' + params.ref; @@ -87,7 +77,7 @@ function fetchGitHubReposApi(params, cb) { .set('Authorization', 'token ' + secrets.github.accessToken) .end(cb); } else { - // will remove this after switching fluxible.io to use accessToken. + // still make call to github API, but will be rate limited. request .get(githubUrl) .set('User-Agent', 'superagent')