Skip to content

k33g/simple-js-octokit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-js-octokit

What

TODO

Install

TODO

Use

WIP

Set token(s)

WIP

  • create a personal web token on your GitHub profile
  • set a environment variable with the token, eg:
export TOKEN_GITHUB_DOT_COM=<YOUR_TOKEN>
export TOKEN_GITHUB_ENTERPRISE=<YOUR_TOKEN>

Initialize GitHub client

const GitHubClient = require('../GitHubClient.js').GitHubClient;

// GitHubClient to connect to GitHub Enterprise
let githubCli = new GitHubClient({
  baseUri:"http://ghe.k33g/api/v3",
  token:process.env.TOKEN_GITHUB_ENTERPRISE
});

// GitHubClient to connect to GitHub.com
let githubCliDotCom = new GitHubClient({
  baseUri:"https://api.github.com",
  token:process.env.TOKEN_GITHUB_DOT_COM
});

Get user informations

// get user information
githubCli.getData({path:"/users/k33g"})
.then(response => {
  console.log(response.headers);
  console.log(response.data);
})
.catch(error => {
  console.log("error", error)
})

or

githubCli.fetchUser({handle:'k33g'}).then(user => {
  console.log(user);
})
.catch(error => {
  console.log("error", error)
})

Create a repository

// create a repository
githubCli.postData({path:"/user/repos", data:{
  name: "killing-repo",
  description: "my killing repository",
  private: false,
  has_issues: true,
  auto_init: true
}})
.then(response => console.log(response.data))
.catch(error => {
  console.log("error", error)
})

or

githubCli.createPublicOrganizationRepository({
  name:"toys",
  description:"my little repo",
  organization:"ACME"
})
.then(repo => {
  console.log(repo)
})

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published