simple-webhooks

0.1.2 • Public • Published

simple-webhooks

All versions prior 1.0.0 are experimental beta versions!

Webhooks made simple!

Features

  • Client and server side implementations.
  • Protected against timing attacks.
  • Sequential executing of jobs.

🚀 Quick start

  1. Install the package with npm.

    npm install simple-webhooks
  2. Start developing.

    Example of a Webhook server listening requests from port 8338.

    // server.js
    const { WebhookServer } = require('simple-webhooks');
     
    const secret = 'shared secret between client and server';
    const port = 8338;
     
    const server = new WebhookServer({
      secret: secret,
      port: port,
      job: (data) => console.log(`Received data: ${data}`);
    });
     
    server.listen().then(() => {
      console.info(`Webhook server running at port ${port}`);
    })

    Example of a Webhook client that can trigger the jobs in the example server running on same host.

    // client.js
    const { WebhookClient } = require('simple-webhooks');
     
    const secret = 'shared secret between client and server';
    const url = 'http://localhost';
    const port = 8338;
     
    const client = new WebhookClient({ secret, url, port });
     
    client.trigger('Hi');

Documentation

Readme

Keywords

Package Sidebar

Install

npm i simple-webhooks

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

14.7 kB

Total Files

10

Last publish

Collaborators

  • morko