import type { ActionFunctionArgs } from "react-router"; import { authenticate } from "../shopify.server"; import { firstDelivery, handleOrderCancelled } from "../services/orders.server"; export const action = async ({ request }: ActionFunctionArgs) => { const { shop, topic, payload, webhookId } = await authenticate.webhook(request); const eventId = request.headers.get("x-shopify-event-id") ?? webhookId; if (!(await firstDelivery(eventId, topic, shop))) return new Response(); await handleOrderCancelled(shop, payload as { admin_graphql_api_id: string }); return new Response(); };