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

node-webhook-relay-server

v1.0.4

Published

Relay webhooks to a websock subscription.

Downloads

9

Readme

Webhook Relay Server (node-webhook-relay-server)

David npm npm GitHub

Webhook Relay Server is a sever in which webhooks can be redirected to websockets for monitoring. The server's goal was to be able to expose web services without exposing LAN networks in a secure fashion

Features

  • Create webhooks for monitoring
  • Create bundles of webhooks to monitor
  • Subscribe to webhooks or bundles
  • Support for HTTP and HTTPS with custom ports
  • Limit max subscriptions per hook or bundle

Config

{
    hooksPath: '/hooks',            //Path to post Webhooks
    hooksSubscriptionPath: '/subscribe/hooks', //Path to subscribe to Hooks
    bundleSubscriptionPath: '/subscribe/bundle', //Path to subscribe to Bundles
    maxSubscriptions: 10,           //Default Max Number of Subscriptions for Hooks/Bundles
    webhookPort: 80,                //Port to Listen for Webhooks
    subscriptionPort: 80,           //Port to Listen for Subscriptions
    useHttps: true,                 //Enable HTTPS
    credentials: {                  //Required for HTTPS
        key: 'secure key',          //Key for HTTPS
        keyFile: 'credentials.key', //Alternatively can load from file
        cert: 'certificate',        //Certificate for HTTPS
        certFile: 'cerdentials.cert'//Alternatively can load from file
    },
    webhookPortSecure: 443,         //Port to Listen for Webhooks on HTTPS
    subscriptionPortSecure: 443,    //Port to Listen for Subscriptions on HTTPS
    httpsOnly: false,               //Only use HTTPS,
    debug: false                    //Enables debug mode
}

Methods

addWebhook({                        // Config and all fields are optional
    endpoint: '/location/:data/:id',   //Custom path for webhook. Fields that start with a colon can be parsed using the BasicProcessor as 'rest_data' in the subscription response.
    id: 'my-hook',                      //ID of webhook. UUID is created when blank
    hookProcessor: processor,           //Processor that handles webhook request. Default is BasicProcessor.
    hookAuthentication: atuhentication, //Webhook Authenticator. Default is NoAuthentication
    subscriptionAuthentication: atuhentication, //Subscription Authenticator. Default is NoAuthentication
    maxSubscriptions: 10,               //Max number of subscriptions for hook
    bundleId: ''                        //ID of bundle to put webhook in. Leaving blank does not put webhook in a bundle
});
returns Promise({
    id: 'my-hook',
    hookPath: '/hooks/location/:data/:id'
    subscriptionPath: '/subscribe/hook/my-hook',
    hookAuthenticationToken: 'token',           //If Hook Authentication reutrns token
    subscriptionAuthenticationToken: 'token',   //If Subscription Authentication reutrns token
})

deleteWebhook(id);                      //Deletes Webhook
returns Promise()

addBundle({                         // Config and all fields are optional
    id: 'my-bundle',                    //ID of bundle. UUID is created when blank
    subscriptionAuthentication: atuhentication, //Subscription Authenticator. Default is NoAuthentication
    maxSubscriptions: 10,               //Max number of subscriptions for bundle
    subscriptionAuthenticationToken: 'token',   //If Subscription Authentication reutrns token
    webhooks: [],                       //Array of webhooks to create
});
returns Promise({
    id: 'my-bundle',
    subscriptionPath: '/subscribe/bundle/my-bundle',
    webhooks: []
})

deleteBundle(id);                       //Deletes Bundle
returns Promise()

listen();                               //Starts Server

Processors

Processors.Basic();                     //Default Processor which can turn endpoints with colons into rest_data. POST data is automatically returned as 'body'.
returns Promise(JSON.stringify({
    source: req.ip,
    body: req.body,
    rest_data: {} //processed endpoint data
}));


//Custom processors can be created with this format
class CustomProcessor extends Processors.Base {
    process(req, webhook) {
        return Promise((res, rej) => {
            var dataToSendToWebsockSubscription = 'Webhook Data';
            res(dataToSendToWebsockSubscription)
        });
    }
}

Authentication

Authentication.None();                          //Default Authentication
Authentication.Basic('username', 'password');   //Basic Username and Password authentication

//Custom authenticators can be created with this format from BaseAuhentication
class CustomAuthentication extends Authentication.Base {
    constructor(token = null) { super(token); }
    verify(req, relay) { return Promise.resolve({ verified: false, id: 0 }); }
    hasToken() { return true; }
    getToken() { return this.token; }
}