Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Add feedback to successful run, and support required webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed Nov 18, 2021
1 parent 7195a98 commit 9b3af55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dist/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
};
};

Expand Down

0 comments on commit 9b3af55

Please sign in to comment.