Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontender-magazine/github-sdk

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontender-magazine/github-sdk

Operations on github

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Github API SDK

JavaScript SDK for Github API. Contain only requests I actually need.

Bages

Travis Codecov branch

Documentation

Table of Contents

ErrorServerResponse

Custom error message for abstract server response

Parameters

  • statusCode number http status code
  • statusText string http status code text
  • message (string | null) error details (optional, default null)

GitHubSDK

SDK for GitHub API

Parameters

upload

Uload file to repository

Parameters

  • props Object upload props
    • props.owner string organization or user name
    • props.repo string repository name
    • props.path string relative file path with file name in it
    • props.message string commit message
    • props.content string base64 encoded content
    • props.branch string name of the branch (optional, default 'master')

Examples

Upload binary file

import fs from 'fs';
import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const image = fs.readFileSync('/path/image.jpg', 'base64');
    const content = await github.upload({
      owner: 'FrontenderMagazine',
      repo: 'article',
      path: 'images/image.jpg',
      message: 'Uploaded image.jpg',
      content: image,
    });
  } catch (error) {
    console.log(error.message);
  }
})();

Upload text file

import { Base64 } from 'js-base64';
import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const readme = Base64.btoa('# Title');
    const content = await github.upload({
      owner: 'FrontenderMagazine',
      repo: 'article',
      path: 'README.md',
      message: 'Uploaded README.md',
      content: readme,
    });
  } catch (error) {
    console.log(error.message);
  }
})();

Returns Promise<Content> uploaded content data

create

Create repository in the organization

Parameters

  • props Object Options
    • props.name string Repository name
    • props.description string Repository description (optional, default null)
    • props.homepage string Link to some related resourse (optional, default null)
    • props.org string? Organization name

Examples

Create repository

import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const results = await github.create({
      name: 'owning-the-role-of-the-front-end-developer',
      description: 'Owning the Role of the Front-End Developer',
      homepage: 'http://alistapart.com/article/owning-the-role-of-the-front-end-developer',
      org: 'FrontenderMagazine',
    });
  } catch (error) {
    console.log(error.message);
  }
})();

Returns Promise<Repository> Repository object

searchForUsers

Search for users

Parameters

Examples

Search for users

import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const results = await github.searchForUsers(['octocat', 'silentimp']);
  } catch (error) {
    console.log(error.message);
  }
})();

Returns Promise<Users> array of users

searchForUser

Search for user

Parameters

  • keyword String login to search

Examples

Search for user

import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const details = await github.searchForUser('octocat');
  } catch (error) {
    console.log(error.message);
  }
})();

Returns Promise<User> user

getUser

Get user details

Parameters

Examples

Get user details

import GitHubSDK from '@frontender-magazine/github-sdk';
(async()=>{
  try {
    const github = new GitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');
    const details = await github.getUser('octocat');
  } catch (error) {
    console.log(error.message);
  }
})();

Returns Promise<User> — user representation

User

User object

Type: User

Content

Content object

Type: Content

Repository

Repository object

Type: Repository

Keywords

FAQs

Package last updated on 03 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc