Skip to content

Commit d39c802

Browse files
committed
chore: webhook payload must be an array
1 parent e650434 commit d39c802

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/huge-eggs-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
chore: require webhook payload to be an array

packages/service-utils/src/node/webhookProducer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ interface WebhookEvent extends Record<string, unknown> {
66
id?: `evt_${string}`;
77
teamId: string;
88
projectId?: string;
9+
/**
10+
* The timestamp your event was triggered at.
11+
*/
912
createdAt?: Date;
1013
/**
11-
* This should match your model defined in api-server.
14+
* An array of your model (defined in api-server). Must not be empty.
1215
*/
13-
payload: Record<string, unknown>;
16+
payload: Record<string, unknown>[];
1417
}
1518

1619
/**
@@ -39,6 +42,7 @@ export class WebhookEventProducer {
3942
*/
4043
async sendEvents(topic: string, events: WebhookEvent[]): Promise<void> {
4144
const parsedEvents: WebhookEvent[] = events.map((event) => {
45+
assert(event.payload.length > 0, "payload must not be empty");
4246
assert(
4347
event.teamId.startsWith("team_"),
4448
"teamId must start with 'team_'",

0 commit comments

Comments
 (0)