mirror of
https://github.com/bendtherules/test-octokit-throttling.git
synced 2026-08-18 13:51:58 +00:00
Add octokit with plugin throttling test
This commit is contained in:
@@ -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;
|
||||
@@ -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}`);
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
declare module '@octokit/plugin-throttling';
|
||||
Reference in New Issue
Block a user