Skip to content

Repository files navigation

Depricated in favor of official github api

Github API SDK

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

Bages

TravisCodecov branch

Documentation

Table of Contents

ErrorServerResponse

Custom error message for abstract server response

Parameters

  • statusCodenumber http status code
  • statusTextstring http status code text
  • message(string | null) error details (optional, default null)

GitHubSDK

SDK for GitHub API

Parameters

upload

Uload file to repository

Parameters

  • propsObject upload props
    • props.ownerstring organization or user name
    • props.repostring repository name
    • props.pathstring relative file path with file name in it
    • props.messagestring commit message
    • props.contentstring base64 encoded content
    • props.branchstring name of the branch (optional, default 'master')

Examples

Upload binary file

importfsfrom'fs';importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constimage=fs.readFileSync('/path/image.jpg','base64');constcontent=awaitgithub.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';importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constreadme=Base64.btoa('# Title');constcontent=awaitgithub.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

  • propsObject Options
    • props.namestring Repository name
    • props.descriptionstring Repository description (optional, default null)
    • props.homepagestring Link to some related resourse (optional, default null)
    • props.orgstring? Organization name

Examples

Create repository

importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constresults=awaitgithub.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

importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constresults=awaitgithub.searchForUsers(['octocat','silentimp']);}catch(error){console.log(error.message);}})();

Returns Promise<Users> array of users

searchForUser

Search for user

Parameters

Examples

Search for user

importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constdetails=awaitgithub.searchForUser('octocat');}catch(error){console.log(error.message);}})();

Returns Promise<User> user

getUser

Get user details

Parameters

Examples

Get user details

importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constdetails=awaitgithub.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

About

Some operations on GitHub that I need in FM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages