Add octokit with plugin throttling test

This commit is contained in:
2019-05-31 19:15:53 +05:30
parent 93ce3a3c8e
commit 0b6f7ffe32
3 changed files with 45 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import Octokit = require('@octokit/rest');
import pluginThrottling = require('@octokit/plugin-throttling');
const Octokit2 = Octokit.plugin(pluginThrottling);
export class MyLibrary {
getRepos() {
const octokit = new Octokit2({
throttle: {
onAbuseLimit: () => {/* ... */ },
onRateLimit: () => {/* ... */ }
}
});
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
octokit.repos.listForOrg({
org: 'octokit',
type: 'public'
}).then(({ data }) => {
console.log('All repos: ', data);
data.forEach(async repo => {
const readmeResponse = await octokit.repos.getReadme({
owner: 'octokit',
repo: repo.name
});
console.log(readmeResponse.data.html_url);
});
})
}
}
export default MyLibrary;
+9
View File
@@ -0,0 +1,9 @@
import { MyLibrary } from './MyLibrary';
console.log('See this in your browser console: Typescript Webpack Starter Launched');
const myLibrary = new MyLibrary();
const result = myLibrary.getRepos();
console.log(myLibrary);
console.log(`A random number ${result}`);
+1
View File
@@ -0,0 +1 @@
declare module '@octokit/plugin-throttling';