backend_shopify_data4autos/app/routes/webhooks.app.uninstalled.jsx
metatroncubeswdev 6cb1d01b0c Inital commit
2025-06-27 18:48:53 -04:00

17 lines
539 B
JavaScript

import { authenticate } from "../shopify.server";
import db from "../db.server";
export const action = async ({ request }) => {
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();
};