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

hook-events

v2.0.1

Published

Client for receiving events from https://hook.events

Downloads

20

Readme

hook-events

This is the official client library to connect to a https://hook.events hook. hook.events is yet another webhook testing took that provides yous a disposable webhook address.

Getting Started

Below, we're using this library and a webhook we created on https://hook.events to listen for call to your webhook and output them to the console

Initialize a new npm project with a default package json by running

npm init -y

Install the hook-events npm package

The hook-event npm package contains a client that lets you easily connect to your hook and register callbacks to be invoked when calls to your hook are made.

npm i hook-events

Create a hook.events client

We'll create a simple Node.js script to create a hook events client that will handle the connection to hook.events for us.

Create a empty index.js file and add the following code to it

const receiver = require('hook-events/receiver');

const client = new receiver.client('https://hookId.hook.events');

You'll need to replace the https://hookId.hook.events hook url with your actual hook you created in the Prerequisites section.

Register a event callback

We want to run some code whenever a call is made to our hook. In this sample app, we'll simply log the requests to the console output

Add the following to index.js

const subscripton = client.onEvent(e => {
   console.log(`Received a ${e.method} call to ${e.path}`);
});

If we run this in Node.js by calling

node index.js 

then open our hook url in a browser, we should see the following output in our console

Received a GET call to /
Received a GET call to /favicon.ico

Cleanup

Whenever we're done using our connection to hook.events, we should remove the listener. We can do this in code by calling dispose on our subscription.

To conserve resources, the hook-event client will only connect and maintain a connection when there's at least one active listener.

Example

const subscripton = client.onEvent(e => {
   // ... code to run on calls to our hook
});

// .... the rest of our app

//Stop listening to our hook
subscription.dispose();