Depricated in favor of official github api
JavaScript SDK for Github API. Contain only requests I actually need.
Custom error message for abstract server response
Parameters
statusCodenumber http status codestatusTextstring http status code textmessage(string | null) error details (optional, defaultnull)
SDK for GitHub API
Parameters
tokenstring github app token
Uload file to repository
Parameters
propsObject upload props
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);}})();- Throws ValidationError Error of fields validation
- Throws ErrorServerResponse Server error
Returns Promise<Content> uploaded content data
Create repository in the organization
Parameters
propsObject Options
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);}})();- Throws ValidationError Error of fields validation
- Throws ErrorServerResponse Server error
Returns Promise<Repository> Repository object
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);}})();- Throws ValidationError Error of fields validation
- Throws ErrorServerResponse Server error
Returns Promise<Users> array of users
Search for user
Parameters
keywordString login to search
Examples
Search for user
importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constdetails=awaitgithub.searchForUser('octocat');}catch(error){console.log(error.message);}})();- Throws ValidationError Error of fields validation
- Throws ErrorServerResponse Server error
Get user details
Parameters
loginString login
Examples
Get user details
importGitHubSDKfrom'@frontender-magazine/github-sdk';(async()=>{try{constgithub=newGitHubSDK('b8f921864bd9a9fb6585b10e6534baa37c4d45fe');constdetails=awaitgithub.getUser('octocat');}catch(error){console.log(error.message);}})();- Throws ValidationError Error of fields validation
- Throws ErrorServerResponse Server error
Returns Promise<User> — user representation
User object
Type: User
Content object
Type: Content
Repository object
Type: Repository