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

@jackdbd/hapi-github-issue-plugin

v1.0.0

Published

Hapi plugin that automatically creates a GitHub issue every time your app encounters an error

Downloads

2

Readme

@jackdbd/hapi-github-issue-plugin

npm version Snyk Vulnerabilities for npm package

Hapi plugin that automatically creates a GitHub issue when a request matches one of the rules you defined.

Installation

npm install @jackdbd/hapi-github-issue-plugin

Preliminary Operations

GitHub personal access token

This Hapi plugin makes a POST request to {{GitHub-API}}/repos/:owner/:repo/issues whenever an HTTP request matches one of the predicates used to configure the plugin itself. To allow this plugin to create an issue in your GitHub repository, you need to configure it with a GitHub personal access token with the required OAuth scopes. You can reuse an existing personal access token, or create a new one.

OAuth scopes for the hapi-github-issue-plugin

Usage

If you register this plugin without passing any options...

import githubIssue from '@jackdbd/hapi-github-issue-plugin'

export const app = async (config) => {

  const server = Hapi.server({ port: 8080 })

  await server.register({ plugin: githubIssue })

  return { server }
}

...it will catch any internal server error and create a GitHub issue like this one:

Telegram message about an internal server error in your Hapi app

You can create a GitHub issue for any kind of request handled by yout Hapi application, as long as you define a request matcher for it. For example, here I configure the plugin to create an issue every time the Hapi app responds with HTTP 500 internal server error, or when it responds with HTTP 418 I'm a Teapot.

// import the plugin itself
import githubIssue from '@jackdbd/hapi-github-issue-plugin'

// define the functions that create the issue title/body somewhere
// in your app, or import them from a library.
import {
  defaultTitleFunction,
  defaultBodyFunction
} from '@jackdbd/hapi-github-issue-plugin/texts'

// define your request predicates somewhere in your app,
// or import them from a library.
import {
  isServerRequestError,
  isUnauthorizedRequestError
} from '@jackdbd/hapi-request-event-predicates'

export const app = async (config) => {

  const server = Hapi.server({ port: 8080 })

  await server.register({
    plugin: githubIssue,
    options: {
      request_event_matchers: [
        // create an issues every time the Hapi app responds with
        // HTTP 500 Internal Server Error, and assign it to bob.
        {
          predicate: isServerRequestError,
          title: defaultTitleFunction,
          body: defaultBodyFunction,
          assignees: ['bob'],
          labels: ['bug', 'matsuri-test']
        },
        // create an issues every time the Hapi app responds with
        // HTTP 418 I'm a teapot, and assign it to john.
        {
          predicate: isTeapotRequestError,
          title: defaultTitleFunction,
          body: defaultBodyFunction,
          assignees: ['john'],
          labels: ['teapot', 'matsuri-test']
        }
      ]
    }
  })

  return { server }
}

Configuration

Options

| Option | Default | Explanation | | --- | --- | --- | | request_event_matchers | see defaultRequestEventMatchers() in register.ts | Each rule controls which request matches, and which title, body, assignees, milestone, labels to use when creating the GitHub issue. |