From 9b3af55c499a9a024fb961a50079fb10a1c864a4 Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Wed, 17 Nov 2021 18:29:00 -0800 Subject: [PATCH] Add feedback to successful run, and support required webhook --- dist/integration/index.js | 10 ++++++++-- integration/index.ts | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dist/integration/index.js b/dist/integration/index.js index 69b8514..a45e3d9 100644 --- a/dist/integration/index.js +++ b/dist/integration/index.js @@ -18,6 +18,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const appUrl = 'https://contentful-app.chec.io'; const handler = (request, context) => __awaiter(void 0, void 0, void 0, function* () { // This only runs on initial execution of an integration + if (request.body.event === 'integrations.create') { + return { + statusCode: 202, + body: '' + }; + } if (request.body.event !== 'integrations.ready') { return { statusCode: 400, @@ -113,8 +119,8 @@ const handler = (request, context) => __awaiter(void 0, void 0, void 0, function }, []); yield Promise.all(installationPromises); return { - statusCode: 204, - body: '', + statusCode: 200, + body: 'Successfully installed Commerce.js for Contentful to the configured spaces', }; }); module.exports = handler; diff --git a/integration/index.ts b/integration/index.ts index 1c04497..b4762e3 100644 --- a/integration/index.ts +++ b/integration/index.ts @@ -12,6 +12,13 @@ const appUrl = 'https://contentful-app.chec.io'; const handler: IntegrationHandler = async (request, context) => { // This only runs on initial execution of an integration + if (request.body.event === 'integrations.create') { + return { + statusCode: 202, + body: '' + } + } + if (request.body.event !== 'integrations.ready') { return { statusCode: 400, @@ -139,8 +146,8 @@ const handler: IntegrationHandler = async (request, context) => { await Promise.all(installationPromises); return { - statusCode: 204, - body: '', + statusCode: 200, + body: 'Successfully installed Commerce.js for Contentful to the configured spaces', }; };