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

23 lines
497 B
JavaScript

import { authenticate } from "../shopify.server";
import db from "../db.server";
export const action = async ({ request }) => {
const { payload, session, topic, shop } = await authenticate.webhook(request);
console.log(`Received ${topic} webhook for ${shop}`);
const current = payload.current;
if (session) {
await db.session.update({
where: {
id: session.id,
},
data: {
scope: current.toString(),
},
});
}
return new Response();
};