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

webhook-simple-forwarder

v2.3.0

Published

Simple webhook forwarder script to send webhooks from a hosted url to your local machine without hassle of setting up tunnels, or port forwarding your own machine, uses webhooks to communicate between client and server

Downloads

83

Readme

Simple webhook forwarder script to send webhooks from a hosted url to your local machine without hassle of setting up tunnels, or port forwarding your own machine, uses webhooks to communicate between client and server

Why?

As opposed to using something like ngrok, this lets you use your own domain/server straight out of the box, which also means you can use the same url to test your webhooks locally while developing.

Also integrates directly into your express app and calls your post endpoints based on the webhook url that is hit, so you don't need to make any changes to your existing configuration

Installation

npm i --save-dev webhook-simple-forwarder

Client Setup (Where you want to receive webhooks)

// your existing index.js
const webhook_forwarder = require('webhook-simple-forwarder')
const express = require('express')
const app = express()

app.use(express.urlencoded({ extended: false }))
app.use(express.json())

app.post('/wh/some-webhook', function(req, res) {
    console.log("Received Webhook!!")
    console.log(req.body)
    
    res.status(200).send("ok")
})

const server = app.listen(process.env.PORT, () => { 

    // add this code block, your key, etc
    if (process.env.NODE_ENV === 'Development')
        webhook_forwarder.client(
            server, 
            'forward.exampledomain.com:3000', 
            process.env.SECRET_KEY, // replace 'SECRET_KEY' with your own
            '/base_path', // optional, can be any base path, for example if you want to allow multiple different client to use the same server
            true // true to omit base url from final request url.
        )
})

Server Setup (Public endpoint for webhooks to come in)

Place this on a server, that can be accessed publicly (e.g. on somedomain.com or via ip), point your webhook to that server, and once you run the client your webhook endpoints will be hit

// index.js
const webhook_forwarder = require('webhook-simple-forwarder')
webhook_forwarder.server(process.env.SECRET_KEY, true, /*optional port, default: 3000 */) // replace 'SECRET_KEY' to match client

Additional Data Returned

req.body._url - provides original url webhook was sent to req.body._headers - provides original headers sent with the webhook req.body - original webhook body

What endpoints can I use?

Use the same endpoints that you have already.

If in production you would receive webhooks to exampledomain.com/wh/some-webhook, and the server hosting this library is located at forward.exampledomain.com, during development you can send your webhooks to forward.exampledomain.com:3000/wh/some-webhook and they will be forwarded to your '/wh/some-webhook' endpoint.

This library supports unlimited endpoints.

How to setup my server?

Any server with a public ip or domain will do, you could probably even use cloud functions for this. You can have multiple clients connected at the same time.

Contributing & Issues

This package was made to fix a specific problem I had, therefore some features may be missing.

Feel free to open an issue or make a pull request.