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 🙏

© 2026 – Pkg Stats / Ryan Hefner

github-webhook-tester

v0.1.3

Published

A Github Webhook Testing Tool

Downloads

7

Readme

GitHub Webhook Tester

The GitHub Webhook Tester is a tool that generates an API exposed over an ngrok tunnel, configures a repositories webhooks to use this API, and provides multiway logging for events.

Overview

When developing or testing a solution that will use Webhooks we often find ourselves creating or modifying an API, creating an ngrok tunnel, removing any redundant hooks from the repository, adding new hooks with the new ngrok.io url, writing the raw logs to a file, or to the console and trying to iterate on the solution. Unless we keep the ngrok tunnel running, when we restart this - we end up with a new URL. This means that all of the hooks we have now have incorrect URLs, making them non-reusable. We also might have to create a lot of boiler plate to simply test one aspect, which takes time and leads to a lot of repeated copypasta.

How does this tool address this?

  1. First get the command line args and parse these - generating any required logger instances
  2. Next build and start a REST API server from the blueprint provided in the --spec argument, see ./example/ for example blueprints
  3. Create an ngrok.io tunnel, and generate a url
  4. Connect to the GitHub repository
  5. Delete any existing hooks that use ngrok.io and exist in the blueprint we provided
  6. Create a brand new set of hooks using the new ngrok.io tunnel and the blueprint in the spec file
  7. Provide multiway logging and execute the callbacks designated in the spec file

Usage

Basic startup

github-webhook-tester --token XXX --repo :owner/:repo

  • This uses the ./example/basic.js blueprint
  • This uses port 5000 for ngrok
  • The token option is an OAuth token with repo scope
  • The repo flag denotes the owner/repo to configure this on
  • Logging is configured for ALL events
  • Logging is defaulted to the console
  • All payloads are logged to the console

Specify different spec file

github-webhook-tester --token XXX --repo :owner/:repo --spec path/to/jsspec

  • Same as above, but with a different blueprint
  • This will use path/to/jsspec

No console logging

github-webhook-tester --token XXX --repo :owner/:repo --noConsoleLogging

  • This uses the ./example/basic.js blueprint
  • Don't print system logs, just webhook payloads

No payload logging, and info level logging

github-webhook-tester --token XXX --repo :owner/:repo --noConsoleOutput --logLevel 4

  • This uses the ./example/basic.js blueprint
  • Don't print payload logs, just system logs
  • Listen for logs at info level

Console logging, File payload logging

mkdir logs && github-webhook-tester --token XXX --repo :owner/:repo --noConsoleOutput --hookfile=./logs/payloads.log

  • create a logs directory
  • Print system logs to the console
  • Print the payload logs to the output file designated in --outputFile
  • This will use ./example/basic.js

See a full breakdown of the options below

Options

  • --logLevel Specify the level of logging for the system logs (defaults to 5 for ALL logs)

  • --spec Specify the blueprint file to use for the API (--spec=./path/bp.js)

  • --repo Specify the target repository to manage the hooks on

  • --token Specify the OAuth token with repo scope to use

  • --port Specify the port to expose to ngrok, defaults to 5000

  • --logfile Specify the file to write the system logs to (--logfile ./logs/log.log)

  • --suppressConsoleLogs Switch off console logging

  • --hookfile Specify the file to write the webhook content to (--hookfile ./logs/payload.log)

  • --suppressConsoleHooks Switch off console output of the payloads

  • --suppressConsole Switch off all console output

Blueprint, a how to...

The spec file is relatively straightforward, the js module you create must return specific keys:

module.exports = {
  hook_endpoint: {
    content_type: json,
    callback: (req, res) => {},
    verb: 'post',
    events: ['*'],
  }

The outer keys of the object we provide to module.exports are our endpoints, in this case /hook_endpoint. For each of these endpoints we provide:

  • content_type for the webhook, this will either be json or form, json makes the most sense here.
  • callback is the function that will be called when a payload is received, the callback function is an express-js callback: https://expressjs.com/en/api.html#app.post.method req is the request, res is your response (send a 200!)
  • verb is the http method, in all cases this will be post - but for flexibility why not :smile:
  • events is an array of events that you want this webhook to listen for, * is a wildcard

Installation

npm install -g github-webhook-tester Don't forget to setup a free ngrok.io account ngrok and setup the token (see the account page)

TODO List

  1. Finish the command line options
  2. Add tests to maintain stability and integrity
  3. Add more spec examples
  4. Add further logging transport layers

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT