feat: add 5 end-to-end provider examples#1
Conversation
17ad950 to
0b0cb4d
Compare
| const mockWebhookPayload = { | ||
| type: "forward", | ||
| connectionId: CONNECTION_ID, | ||
| providerConfigKey: "github", | ||
| payload: { | ||
| action: "opened", | ||
| pull_request: { | ||
| number: 99, | ||
| title: "Add relayfile examples", | ||
| html_url: "https://github.com/acme/api/pull/99", | ||
| user: { login: "agent-bot" }, | ||
| }, | ||
| repository: { | ||
| full_name: "acme/api", | ||
| }, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
🔴 Mock webhook payload missing required fields causes example 03 to crash at handleWebhook
The mock forward-webhook payload at examples/03-provider-with-adapter/index.ts:63-79 is missing the fields that extractForwardMetadata (packages/nango/src/webhook.ts:98-154) requires. The inner payload object only has action, pull_request, and repository, but the normalizer looks for objectType/object_type/resource/entity (for object type), objectId/object_id/id (for object ID), and eventType/event_type/topic/event (for event type). Since none of these are present, resolveForwardEventType returns undefined, causing a NangoWebhookError: "Forwarded Nango webhook payload is missing explicit event metadata" to be thrown at webhook.ts:124-129. Because the handleWebhook call at line 91 is not inside a try-catch, the entire example crashes immediately, never reaching Steps 2–4. The README states "The example uses mock webhook data so it runs without real GitHub events" implying it should work through the webhook normalization step.
Required fields for the inner payload
The mock payload needs fields like objectType (e.g. "pull_request"), objectId or id (e.g. 99), and either eventType or event/topic (e.g. "pull_request.opened") in the nested payload object for extractForwardMetadata to succeed.
| const mockWebhookPayload = { | |
| type: "forward", | |
| connectionId: CONNECTION_ID, | |
| providerConfigKey: "github", | |
| payload: { | |
| action: "opened", | |
| pull_request: { | |
| number: 99, | |
| title: "Add relayfile examples", | |
| html_url: "https://github.com/acme/api/pull/99", | |
| user: { login: "agent-bot" }, | |
| }, | |
| repository: { | |
| full_name: "acme/api", | |
| }, | |
| }, | |
| }; | |
| const mockWebhookPayload = { | |
| type: "forward", | |
| connectionId: CONNECTION_ID, | |
| providerConfigKey: "github", | |
| payload: { | |
| action: "opened", | |
| objectType: "pull_request", | |
| objectId: "99", | |
| event: "pull_request", | |
| pull_request: { | |
| number: 99, | |
| title: "Add relayfile examples", | |
| html_url: "https://github.com/acme/api/pull/99", | |
| user: { login: "agent-bot" }, | |
| }, | |
| repository: { | |
| full_name: "acme/api", | |
| }, | |
| }, | |
| }; |
Was this helpful? React with 👍 or 👎 to provide feedback.
c497d98 to
b768df5
Compare
b768df5 to
ece915a
Compare
Five runnable TypeScript examples covering the core provider patterns: - Nango GitHub proxy with optional baseUrl override - Composio proxy with toolkit/action resolution - Provider + Adapter webhook→writeback flow (core pattern) - Multi-provider registry in a single app - Health checks and connection listing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b65be05 to
bd9644f
Compare
Examples
Shows the new optional baseUrl pattern throughout.