miniapp-projects/app/routes/webhooks.app.uninstalled.tsx
WangDL 9988077057 feat: 添加微信小程序项目完整代码
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 22:05:46 +08:00

18 lines
615 B
TypeScript

import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import db from "../db.server";
export const action = async ({ request }: ActionFunctionArgs) => {
const { shop, session, topic } = await authenticate.webhook(request);
console.log(`Received ${topic} webhook for ${shop}`);
// Webhook requests can trigger multiple times and after an app has already been uninstalled.
// If this webhook already ran, the session may have been deleted previously.
if (session) {
await db.session.deleteMany({ where: { shop } });
}
return new Response();
};