MCPcopy Create free account
hub / github.com/Shopify/function-examples / action

Function action

sample-apps/discounts/app/routes/webhooks.jsx:4–21  ·  view source on GitHub ↗
({ request })

Source from the content-addressed store, hash-verified

2import db from "../db.server";
3
4export const action = async ({ request }) => {
5 const { topic, shop, session } = await authenticate.webhook(request);
6
7 switch (topic) {
8 case "APP_UNINSTALLED":
9 if (session) {
10 await db.session.deleteMany({ where: { shop } });
11 }
12 break;
13 case "CUSTOMERS_DATA_REQUEST":
14 case "CUSTOMERS_REDACT":
15 case "SHOP_REDACT":
16 default:
17 throw new Response("Unhandled webhook topic", { status: 404 });
18 }
19
20 throw new Response();
21};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected