File tree 4 files changed +67
-84
lines changed
4 files changed +67
-84
lines changed Original file line number Diff line number Diff line change 1
- "use strict" ;
1
+ const {
2
+ createLambdaFunction,
3
+ createProbot,
4
+ } = require ( "@probot/adapter-aws-lambda-serverless" ) ;
2
5
3
- const { createProbot } = require ( "probot" ) ;
4
- const app = require ( "./app" ) ;
6
+ const appFn = require ( "./" ) ;
5
7
6
- const probot = createProbot ( ) ;
7
- const loadingApp = probot . load ( app ) ;
8
-
9
- module . exports . webhooks = async ( event , context ) => {
10
- try {
11
- await loadingApp ;
12
-
13
- // Ends function immediately after callback
14
- context . callbackWaitsForEmptyEventLoop = false ;
15
-
16
- // this could will be simpler once we ship `verifyAndParse()`
17
- // see https://github.com/octokit/webhooks.js/issues/379
18
- await probot . webhooks . verifyAndReceive ( {
19
- id :
20
- event . headers [ "X-GitHub-Delivery" ] ||
21
- event . headers [ "x-github-delivery" ] ,
22
- name : event . headers [ "X-GitHub-Event" ] || event . headers [ "x-github-event" ] ,
23
- signature :
24
- event . headers [ "X-Hub-Signature-256" ] ||
25
- event . headers [ "x-hub-signature-256" ] ,
26
- payload : JSON . parse ( event . body ) ,
27
- } ) ;
28
-
29
- return {
30
- statusCode : 200 ,
31
- body : '{"ok":true}' ,
32
- } ;
33
- } catch ( error ) {
34
- console . log ( error ) ;
35
-
36
- return {
37
- statusCode : error . status || 500 ,
38
- error : "ooops" ,
39
- } ;
40
- }
41
- } ;
8
+ module . exports . webhooks = createLambdaFunction ( appFn , {
9
+ probot : createProbot ( ) ,
10
+ } ) ;
Original file line number Diff line number Diff line change 9
9
"test" : " node test.js"
10
10
},
11
11
"dependencies" : {
12
- "probot" : " ^11 .0.5 "
12
+ "@ probot/adapter-aws-lambda-serverless " : " ^2 .0.0 "
13
13
},
14
14
"repository" : " https://github.com/probot/example-aws-lambda-serverless" ,
15
15
"keywords" : [],
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ const assert = require("uvu/assert");
4
4
const nock = require ( "nock" ) ;
5
5
nock . disableNetConnect ( ) ;
6
6
7
- const { Probot, ProbotOctokit } = require ( "probot" ) ;
7
+ const {
8
+ Probot,
9
+ ProbotOctokit,
10
+ } = require ( "@probot/adapter-aws-lambda-serverless" ) ;
8
11
9
12
const app = require ( "./app" ) ;
10
13
You can’t perform that action at this time.
0 commit comments