Class: WebhookServer

WebhookServer(opt) → {WebhookServer}

HTTP Webhook server that executes a job if the client uses the same secret to sign the request.

The signature is delivered in the X-Hub-Signature header.

Constructor

new WebhookServer(opt) → {WebhookServer}

Creates a HTTP Webhook server.

Parameters:
Name Type Description
opt Object

Options for the server.

Properties
Name Type Attributes Default Description
secret String

Shared secret between server and client for HMAC signature verification.

job job

The function that gets executed when Webhook is triggered.

port Number <optional>
8338

Port of the Webhook server.

Source:
Returns:
  • The created server.
Type
WebhookServer

Methods

(async) close()

Stops listening for new connections.

Parameters:
Type Description
Promise

Resolves when server has stopped listening.

Source:

(async) listen(port)

Starts listening for the connections.

Parameters:
Name Type Description
port Number

Port to listen to.

Promise

Resolves when server is listening.

Source:

Type Definitions

job(req, res)

Callback funtion that gets called when Webhook server recieves data that is valid.

Parameters:
Name Type Description
req IncomingMessage
res ServerResponse
Source: