Skip to content

Commit

Permalink
fix: restore landing page (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajschmidt8 committed Jan 9, 2023
1 parent abab4d3 commit 21610ac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
49 changes: 28 additions & 21 deletions lambda-function.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
module.exports = lambdaFunction;

const lowercaseKeys = require("lowercase-keys");
const { template } = require("./views/probot");

async function lambdaFunction(probot, event, context) {
try {
// lowercase all headers to respect headers insensitivity (RFC 7230 $3.2 'Header Fields', see issue #62)
const headersLowerCase = lowercaseKeys(event.headers);

// this will be simpler once we ship `verifyAndParse()`
// see https://github.com/octokit/webhooks.js/issues/379
await probot.webhooks.verifyAndReceive({
id: headersLowerCase["x-github-delivery"],
name: headersLowerCase["x-github-event"],
signature:
headersLowerCase["x-hub-signature-256"] ||
headersLowerCase["x-hub-signature"],
payload: event.body,
});

return {
if (event.httpMethod === "GET" && event.path === "/probot") {
const res = {
statusCode: 200,
body: '{"ok":true}',
};
} catch (error) {
return {
statusCode: error.status || 500,
error: "ooops",
headers: {
"Content-Type": "text/html",
},
body: template,
};
return res;
}

// lowercase all headers to respect headers insensitivity (RFC 7230 $3.2 'Header Fields', see issue #62)
const headersLowerCase = lowercaseKeys(event.headers);

// this will be simpler once we ship `verifyAndParse()`
// see https://github.com/octokit/webhooks.js/issues/379
await probot.webhooks.verifyAndReceive({
id: headersLowerCase["x-github-delivery"],
name: headersLowerCase["x-github-event"],
signature:
headersLowerCase["x-hub-signature-256"] ||
headersLowerCase["x-hub-signature"],
payload: event.body,
});

return {
statusCode: 200,
body: JSON.stringify({ ok: true }),
};

}
1 change: 0 additions & 1 deletion views/probot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports.template = `
<h4 class="alt-h4 text-gray-light">Need help?</h4>
<div class="d-flex flex-justify-center mt-2">
<a href="https://probot.github.io/docs/" class="btn btn-outline mr-2">Documentation</a>
<a href="https://probot-slackin.herokuapp.com/" class="btn btn-outline">Chat on Slack</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 21610ac

Please sign in to comment.