Skip to content

WebhookShard

A Webhook Shard created within a Conduit.

Constructors

new WebhookShard()

1
new WebhookShard(options: Pick<WebhookConnectionOptions, "baseURL" | "secret" | "startServer" | "subscriptionRoute">, server?: Express): WebhookShard

Builds up a Webhook Shard.

Parameters

ParameterTypeDescription
optionsPick<WebhookConnectionOptions, "baseURL" | "secret" | "startServer" | "subscriptionRoute">The options for the shard.
server?ExpressThe Express server to handle the subscription notifications.

Returns

WebhookShard

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:67

Properties

PropertyModifierTypeDescription
baseURLreadonlystringThe base URL of the server for setting up the callback.
secretreadonlystringThe secret of the shard.
serverreadonlyExpressThe Express server to handle the subscription notifications.
startServerreadonlyboolean

Whether to start the server at start.

Default

false
subscriptionRoutereadonlystringThe route where the subscription notifications will be sent.

Accessors

conduitId

1
get conduitId(): string

The id of the Conduit which this shard belongs to.

Returns

string

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:91


shardId

1
get shardId(): string

The id of the shard.

Returns

string

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:99


url

1
get url(): string

The URL used for receiving the subscription notifications. This is the combination of the baseURL and the subscriptionRoute.

Returns

string

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:84

Methods

makeDebug()

1
makeDebug(...args: any[]): void

Sends a debug packet to the parent thread to make a debug.

Parameters

ParameterTypeDescription
argsany[]The arguments to send.

Returns

void

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:180


makeWarn()

1
makeWarn(...args: any[]): void

Sends a warn packet to the parent thread to make a warning.

Parameters

ParameterTypeDescription
argsany[]The arguments to send.

Returns

void

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:188


post()

1
post(
2
headers: IncomingHttpHeaders,
3
body: any,
4
verification: (challenge: string) => any,
5
success: () => any,
6
invalidSignature?: () => any): Promise<any>

Used for handling incoming Twitch requests in your custom non-Express server.

Parameters

ParameterTypeDescription
headersIncomingHttpHeadersThe headers of the request.
bodyanyThe body of the request.
verification(challenge: string) => anyA callback to be called when the request is a webhook callback verification and you need to send the challenge.
success() => anyA callback to be called when the handling has suceeded. You will need to send a 200 status in the response after that.
invalidSignature?() => anyA callback which is executed when the signature that has been sent by the requester is incorrect.

Returns

Promise<any>

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:112


sendPacket()

1
sendPacket(packet: object): void

Sends a packet to the parent thread.

Parameters

ParameterTypeDescription
packetobjectThe packet to send.

Returns

void

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:196


start()

1
start(port?: number, callback?: () => void): Promise<void>

Starts the shard.

Parameters

ParameterTypeDescription
port?numberThe port to start the server at if the startServer option is set to true.
callback?() => voidA callback to be called when the server is started if the startServer option is set to true.

Returns

Promise<void>

Source

twitchfy/packages/eventsub/src/structures/WebhookShard.ts:154