Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.39 KB

File metadata and controls

55 lines (41 loc) · 1.39 KB

GithubClient

GithubClient is the recommended entry point when you need a shared token or User-Agent applied to every request without configuring each endpoint individually.

import { GithubClient } from "@openally/github.sdk";

const github = new GithubClient({
  token: process.env.GITHUB_TOKEN,
  userAgent: "my-app/1.0.0"
});

// Iterate over all open pull requests
for await (const pr of github.repos.OpenAlly["github.sdk"].pulls()) {
  console.log(pr.title);
}

// Collect all tags at once
const tags = await github.repos.OpenAlly["github.sdk"].tags();

// List all repositories for a user
const userRepos = await github.users.torvalds.repos();

Constructor

new GithubClient(options?: GithubClientOptions)
interface GithubClientOptions {
  /**
   * GitHub personal access token sent as a Bearer authorization header.
   * Required for private resources and to increase the API rate limit.
   */
  token?: string;

  /**
   * Value for the User-Agent request header.
   * @default "@openally/github.sdk/1.0.0"
   */
  userAgent?: string;
}

Properties

  • reposReposProxy — see repos
  • usersUsersProxy — see users

Methods

  • fetchRawFilePromise<string> when no parser is provided, Promise<T> when parser: "json" or a custom parser function is provided. — see fetchRawFile