How to use @octokit/core - 3 common examples

To help you get started, we’ve selected a few @octokit/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github w3c / validate-repos / lib / octokit.js View on Github external
/* eslint-env node */
/* istanbul ignore file */

"use strict";

const config = require("../config.json");
const Octokit = require("@octokit/core").Octokit
  .plugin(require("@octokit/plugin-throttling"));

const MAX_RETRIES = 3;

const octokit = new Octokit({
  auth: config.ghToken,
  throttle: {
    onRateLimit: (retryAfter, options) => {
      if (options.request.retryCount < MAX_RETRIES) {
        console.warn(`Rate limit exceeded, retrying after ${retryAfter} seconds`)
        return true;
      } else {
        console.error(`Rate limit exceeded, giving up after ${MAX_RETRIES} retries`);
        return false;
      }
    },
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / node_modules / @actions / github / lib / utils.js View on Github external
exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
const Context = __importStar(require("./context"));
const Utils = __importStar(require("./internal/utils"));
// octokit + plugins
const core_1 = require("@octokit/core");
const plugin_rest_endpoint_methods_1 = require("@octokit/plugin-rest-endpoint-methods");
const plugin_paginate_rest_1 = require("@octokit/plugin-paginate-rest");
exports.context = new Context.Context();
const baseUrl = Utils.getApiBaseUrl();
const defaults = {
    baseUrl,
    request: {
        agent: Utils.getProxyAgent(baseUrl)
    }
};
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
/**
 * Convience function to correctly format Octokit Options to pass into the constructor.
 *
 * @param     token    the repo PAT or GITHUB_TOKEN
 * @param     options  other options to set
 */
function getOctokitOptions(token, options) {
    const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller
    // Auth
    const auth = Utils.getAuthString(token, opts);
    if (auth) {
        opts.auth = auth;
    }
    return opts;
}
exports.getOctokitOptions = getOctokitOptions;
github octokit / routes / bin / notify-users.js View on Github external
const APP_ID = 37848;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const EVENT_TYPE = process.env.INPUT_EVENT_TYPE;
const VERSION = process.env.INPUT_VERSION;

const { createAppAuth } = require("@octokit/auth-app");
const { Octokit } = require("@octokit/core");
const { paginateRest } = require("@octokit/plugin-paginate-rest");

const OctokitWithPagination = Octokit.plugin(paginateRest);

main();

async function main() {
  try {
    const octokit = new OctokitWithPagination({
      auth: {
        id: APP_ID,
        privateKey: PRIVATE_KEY
      },
      authStrategy: createAppAuth
    });

    const installations = await octokit.paginate("GET /app/installations", {
      mediaType: { previews: ["machine-man"] },
      per_page: 100

@octokit/core

Extendable client for GitHub's REST & GraphQL APIs

MIT
Latest version published 7 months ago

Package Health Score

93 / 100
Full package analysis