Skip to content

RickWong/local-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

local-webhook

Zero-configuration localhost webhooks. Do not use in production.

banner

Installation

yarn add -D local-webhook express

Note: express is a required peer dependency.

Usage

Setup and generate webhook as a Promise:

import LocalWebhook from 'local-webhook';

await LocalWebhook.startServer({ subdomain: "sushi" });

// Generate an awaitable webhook Promise.
const webhook = LocalWebhook.getPromise("wasabi");

// This URL can be shared with third-party services.
// Ex: "https://sushi.localhost.run/wasabi"
webhook.getWebhookUrl(); 

// Handle third-party service's webhook request once.
webhook.then(({ req, res }) => {
    res.send("Hello from promise, wasabi");
});

// Awaitable if necessary.
await webhook;

Generate webhook as an Observable:

// Generate a webhook Observable.
const webhook = LocalWebhook.getObservable("ichiban");

// This URL can be shared with third-party services.
// Ex: "https://sushi.localhost.run/ichiban"
webhook.getWebhookUrl(); 

// Handle third-party service's webhook requests each time it's called.
webhook.subscribe(({ req, res }) => {
  res.send("Hello from observable, ichiban");
});

Check the example and tests for much more options.

Community

Let's start one together! After you ★ this project, follow me @Rygu on Twitter.

Thanks

License

BSD 3-Clause license. Copyright © 2018, Rick Wong. All rights reserved.

About

💕 Zero-config webhooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published