npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

octopie

v1.3.0

Published

An easy way to add GitHub hooks to your project

Downloads

7

Readme

What is this?

Octopie is allows you to automate your GitHub workflow by binding into GitHub hooks

How do I use this?

First off, require Octopie into your project and boot up an instance:

var Octopie = require('octopie')
var myServer = new Octopie({
  url: 'https://path.to/my/server'
  authToken: '...'
})

Next, define repositiories you'd like to watch:

myServer.add('8bitDesigner/cool-new-repo')
        .add('8bitDesigner/another-repo')

Define events you want to receive, and your callbacks to them:

myServer.on('pull_request', function(event) {
  console.log('New pull request + event.action + ': ' +event.pull_request.title)
  // Logs out "New pull request opened: Name of Pull Request"
})

And lastly, start listening for new events:

myServer.listen(80, function() {
  console.log('listening on port 80')
})

Documentation on which GitHub events are available and what they're fired in response to can be found here: http://developer.github.com/v3/repos/hooks/

Ocotpie options

The Octopie constructor takes an object whose arguments are outline below, eg: new Octopie({ url: '...', token: '...' })

url

This should be the URL of the Octopie server. The server needs to be publically accessible, as GitHub will need to reach it with its event requests.

authToken

This should be a GitHub auth token which will be used to log into GitHub and register hook events. Keep this secret, safe, and out of source control, as auth tokens are effectively passwords.

You can generate an auth token for the current GitHub user here: https://github.com/settings/tokens/new

shouldSyncHooks

Boolean (defaults to false) - should OctoPie attempt to install any configured hooks on the its tracked repositories? Off by default as this requires its access token to have admin privileges on the repos it tracks.

Octopie methods

Each instance of the Octopie server has the following methods:

Octopie#add('user/repo')

Adds a repo to the list of repositiories to watch.

server = new Octopie({ })
server.add('my/repository')

Octopie#on('event', callback)

Registers an callback to be run every time GitHub pings our server with the requested event. The callback will be run with one argument, a the JSON payload from GitHub.

server = new Octopie({ })
server.on('push', function(data) {
  console.log('Commits pushed!', data.commits)
})

Octopie#listen(80)

Starts listening for events on the given port. If shouldSyncHooks is true, it causes the server to register all requested hooks with GitHub before listening for any events.

server = new Octopie({ })
server.listen(80)