From 97d369de5710e55e6eb3f22018ab918174fe1143 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 28 Oct 2021 14:39:04 -0700 Subject: [PATCH] Add handler for readiness probe --- README.md | 1 + index.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c1f4039..fb93f48 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ npm run build | Event | Action | Template | | -------------------------- | ----------------------------------- | ---------------------- | +| `readiness.probe` | API checking on readiness | - | | `integrations.create` | Initial setup | - | | `orders.create` | Send customer receipt | "Order receipt" | | `orders.physical.shipment` | Send customer shipment notification | "Item shipped" | diff --git a/index.js b/index.js index e2e47df..a2a5ddb 100644 --- a/index.js +++ b/index.js @@ -67,6 +67,14 @@ module.exports = async function handler(request, context) { // Verify webhook authenticity verifyWebhook(request.body, context.webhookSigningKey); + // If it's a readiness probe, tell it we're good. + if (request.body.event === 'readiness.probe') { + return { + statusCode: 204, + body: '', + }; + } + // Fetch merchant and integration info const merchant = await context.merchant(); const merchantId = merchant.id;