Libraries.io Simple GitHub Client
npm install libhubLibraries.io minimalistic GitHub client.
- Dead simple API
- Promise based
- Support for caching + conditional requests (optional)
- Support for pagination using link headers
- Node.js v4.2.x
``javascript
const Client = require('libhub')
let github = new Client(token)
// GET
github.get(/repos/librariesio/libhub/issues)
.then( (issues) => {
console.log(issues)
})
// POST
github.post(/repos/librariesio/libhub/issues, {}, issueBody)
.then( (issue) => {
console.log(issue)
})
`
Available methods: get, post, patch, put, delete
`javascript/repos/librariesio/${invalidId}
// 3xx/4xx/5xx errors
github.get()`
.then( (repo) => {
// This won't happen
})
.catch( (err) => {
console.log(err.statusCode) // 404
})
The Client constructor takes an optional cache object that should have a get and a set method. Both should return a Promise.
`javascript
const Client = require('libhub')
const InMemoryCache = require('./test/cache')
let github = new Client(token, { cache: InMemoryCache })
github.get(/repos/librariesio/libhub/issues)`
.then( (issues) => {
console.log(issues)
})
`javascript/events
github.get(, { allPages: true })`
.then( (events) => {
console.log(events.length) // All the user public events ~300
})
Well, simplicity. Most GitHub clients I used implement unnecessary abstractions. For example, octonode. This means that you need to check GitHub API documentation and Octonode documentation to perform any action. This gets boring pretty quickly.
With LibHub, you just need to lookup the resource URL and use it. Also, ES6 interpolation.
`javascript/repos/${owner}/${repo}/branches/${branch}
github.get()``
MIT