-
Notifications
You must be signed in to change notification settings - Fork 387
Add addHandler and getHandler functions #205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! Had a couple of comments but the methods themselves are pretty much good to go!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits, but looks good to me!
(Note that we shouldn't merge this yet!)
f0c7e66
to
ffa858a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Had a couple of non-blocking comments but I'm otherwise happy with this.
Hey guys. I understand the need to remove the webhook handler from the
|
Co-authored-by: Paulo Margarido <64600052+paulomarg@users.noreply.github.com>
c09389b
to
682e5dd
Compare
@arsnl hey, i'm trying your example: i get {
webhookSubscriptionCreate: {
userErrors: [],
webhookSubscription: { id: 'gid://shopify/WebhookSubscription/1069434383796' }
}
}
// -> APP_UNINSTALLED Webhook was successfully registered however, when i uninstall the app the route Shopify.Webhooks.Registry.reloadHandlers = () => {
// Only reload if the webhookRegistry is empty
if (!Shopify.Webhooks.Registry.webhookRegistry.length) {
Shopify.Webhooks.Registry.webhookRegistry = WEBHOOK_REGISTRY_ENTRIES;
}
};
console.log(req.body);
const isWebhookPath = Shopify.Webhooks.Registry.isWebhookPath(
"/api/shopify/webhooks"
);
console.log("isWebhookPath:", isWebhookPath); // -> true
try {
const response = await Shopify.Webhooks.Registry.process(req, res);
console.log(response);
console.log(`Webhook processed, returned status code 200`);
} catch (error) {
console.log(`Failed to process webhook: ${error}`);
} however
|
+1 Experiencing exactly the same in a NEXT.js app, did you solve it @cmnstmntmn |
TO-DO
webhookRegistry
to have a dictionary withtopic
as key and a dictionary with{path, topic, webhookHandler}
as valueswebhookHandler
parameterregister
function, handle multiple webhooks in a loop asregisterAll
registerAll
WHY are these changes introduced?
register
functionWHAT is this pull request doing?
loadHandler
method out ofregister
that adds the handler to the registryregister
Type of change
Checklist