Files
airllm-fork-nodejs/node_modules/octokit/dist-src/octokit.js
2026-02-05 15:27:49 +08:00

46 lines
1.4 KiB
JavaScript

import { Octokit as OctokitCore } from "@octokit/core";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
import { retry } from "@octokit/plugin-retry";
import { throttling } from "@octokit/plugin-throttling";
import { VERSION } from "./version.js";
import { RequestError } from "@octokit/request-error";
const Octokit = OctokitCore.plugin(
restEndpointMethods,
paginateRest,
paginateGraphQL,
retry,
throttling
).defaults({
userAgent: `octokit.js/${VERSION}`,
throttle: {
onRateLimit,
onSecondaryRateLimit
}
});
/* v8 ignore next no need to test internals of the throttle plugin -- @preserve */
function onRateLimit(retryAfter, options, octokit) {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
return true;
}
}
/* v8 ignore next no need to test internals of the throttle plugin -- @preserve */
function onSecondaryRateLimit(retryAfter, options, octokit) {
octokit.log.warn(
`SecondaryRateLimit detected for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
return true;
}
}
export {
Octokit,
RequestError
};