Skip to content

williamkapke/github-event-poller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-event-poller

This module polls GitHub Events APIs while obeying GitHub's polling rules.

js-standard-style

Install It...

$ npm install --save github-event-poller

Use it..

poller(url, callback, customInterval)

url:

callback:

The callback will be called with the results each time the url is polled. If there are no changes (304 Not Modified) the result data will be an empty array.

customInterval:

An optional function that is passed GitHub's requested interval limit and returns the number of seconds until the next poll. e.g.: (interval) => 60 // seconds

Example

const poller = require('github-event-poller');
const url = `https://api.github.com/repos/nodejs/node/events?per_page=10`

poller(url, ({data, limit, remaining, reset, interval}) => {
  console.log('Rate Limit:', JSON.stringify({limit, remaining, reset, interval}))
  console.log(data) // will be empty if the API returns a 304 Not Modified
})

// override the default error handler
poller.onerror = (error) => {
  console.log(error)
  return 60 // the number of seconds to wait before trying again
}

License

MIT

About

Poll GitHub Events API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published