Skip to content

Commit

Permalink
Add subtopics to webhook handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
lizkenyon committed Jan 31, 2024
1 parent 858e69a commit 04ef994
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function authenticateWebhookFactory<
topic: check.topic as Topics,
webhookId: check.webhookId,
payload: JSON.parse(rawBody),
subTopic: check.subTopic || null,
session: undefined,
admin: undefined,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ interface Context<Topics = string | number | symbol> {
* ```
*/
payload: JSONValue;
/**
* The sub-topic of the webhook. This is only available for certain webhooks.
*
* @example
* <caption>Webhook sub-topic.</caption>
* <description>Get the webhook sub-topic.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* const { subTopic } = await authenticate.webhook(request);
* return new Response();
* };
* ```
*
*/
subTopic: string | undefined;
}

export interface WebhookContextWithoutSession<Topics = string | number | symbol>
Expand Down

0 comments on commit 04ef994

Please sign in to comment.