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

hookshare

v0.1.4

Published

A tool for sharing WebHooks between multiple dev environments.

Downloads

2

Readme

HookShare

Automated Tests

A tool for sharing WebHooks between multiple dev environments.

Install

Run npm i -g hookshare

The Problem

When building WebHook integration with a 3rd party services, configuring a proxy to forward requests to a local environment, and managing multiple engineers' individual environments simultaneously becomes very cumbersome.

The Solution

A relay service that is accessible on the public internet that receives WebHook events and forwards them to multiple recipients on private networks.

HookShare architecture

This is an interesting problem because it is impossible to send multiple responses to one HTTP request. HookShare aims to solve this by being flexible and providing several different options to handle this depending on the use cases.

Getting started

There is two major components to HookShare, a Relay and a Client.

Relay

The Relay is accessible from the public internet and receives requests from 3rd parties.

Config File

Example config:

{
  "routes": {
    "/test": {
      "response": {
        "type": "static",
        "status": 200,
        "body": "{\"status\":\"OK\"}",
        "headers": {
          "content-type": "application/json"
        }
      },
      "forward": {
        "target": "https://localhost",
        "sslVerification": false
      }
    }
  }
}

Relay Environment Variables

  • HTTP_PORT: The port to listen on for HTTPS. Defaults to "8080".
  • LOG_LEVEL: The level of details logged. Defaults to "warn".
  • CONFIG_PATH: The path to a config file. Defaults to "config.json".
  • BROADCAST_RESPONSE_TIMEOUT_MS: How long to wait before clients to respond to messages. Defaults to "5000".

Relay Startup

Run hs-relay

Client

The Client connects to a target Relay and "replays" any requests received by the Relay.

Client Environment Variables

  • RELAY_HOSTNAME: The full hostname where the Relay server is running. Defaults to ws://localhost:8080.

Client Startup

Run hs-client

Response Types

static

Params

  • type=static
  • status: status code for static response
  • body: body to use for static response
  • headers: headers to use for static response

When a static response is defined in the configuration, the Relay will forward the request details to all connected Clients and respond with the details defined in the configuration.

This can be useful when the response to the WebHook doesn't need to be dynamic.

successful-client

Params

  • type=successful-client
  • expectedStatus: status code to match for successful response

When a successful-client response is defined in the configuration, the Relay will forward the request details to all connected Clients and respond with the details from the first client to respond with a status matching expectedStatus. All other client responses will be ignored.

This can be useful when working with on larger teams where each engineer might have their own local datastore. In theory, only the relevant will know about the given resource and thus respond successfully.

random-client

Params

  • type=random-client

When a random-client response is defined in the configuration, the Relay will respond with the details returned to one of the clients.

This can be useful when the 3rd party needs a dynamic response from a specific client, and it is unlikely

coming soon...

  • dynamic: write a function to generate a response
  • dynamic-client: write a function to pick the client response