Skip to content

Commit 21610ac

Browse files
authored
fix: restore landing page (#111)
1 parent abab4d3 commit 21610ac

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

lambda-function.js

+28-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
module.exports = lambdaFunction;
22

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

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

10-
// this will be simpler once we ship `verifyAndParse()`
11-
// see https://github.com/octokit/webhooks.js/issues/379
12-
await probot.webhooks.verifyAndReceive({
13-
id: headersLowerCase["x-github-delivery"],
14-
name: headersLowerCase["x-github-event"],
15-
signature:
16-
headersLowerCase["x-hub-signature-256"] ||
17-
headersLowerCase["x-hub-signature"],
18-
payload: event.body,
19-
});
20-
21-
return {
8+
if (event.httpMethod === "GET" && event.path === "/probot") {
9+
const res = {
2210
statusCode: 200,
23-
body: '{"ok":true}',
24-
};
25-
} catch (error) {
26-
return {
27-
statusCode: error.status || 500,
28-
error: "ooops",
11+
headers: {
12+
"Content-Type": "text/html",
13+
},
14+
body: template,
2915
};
16+
return res;
3017
}
18+
19+
// lowercase all headers to respect headers insensitivity (RFC 7230 $3.2 'Header Fields', see issue #62)
20+
const headersLowerCase = lowercaseKeys(event.headers);
21+
22+
// this will be simpler once we ship `verifyAndParse()`
23+
// see https://github.com/octokit/webhooks.js/issues/379
24+
await probot.webhooks.verifyAndReceive({
25+
id: headersLowerCase["x-github-delivery"],
26+
name: headersLowerCase["x-github-event"],
27+
signature:
28+
headersLowerCase["x-hub-signature-256"] ||
29+
headersLowerCase["x-hub-signature"],
30+
payload: event.body,
31+
});
32+
33+
return {
34+
statusCode: 200,
35+
body: JSON.stringify({ ok: true }),
36+
};
37+
3138
}

views/probot.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module.exports.template = `
2525
<h4 class="alt-h4 text-gray-light">Need help?</h4>
2626
<div class="d-flex flex-justify-center mt-2">
2727
<a href="https://probot.github.io/docs/" class="btn btn-outline mr-2">Documentation</a>
28-
<a href="https://probot-slackin.herokuapp.com/" class="btn btn-outline">Chat on Slack</a>
2928
</div>
3029
</div>
3130
</div>

0 commit comments

Comments
 (0)