File tree Expand file tree Collapse file tree 4 files changed +67
-84
lines changed
Expand file tree Collapse file tree 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" ) ;
25
3- const { createProbot } = require ( "probot" ) ;
4- const app = require ( "./app" ) ;
6+ const appFn = require ( "./" ) ;
57
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 99 "test" : " node test.js"
1010 },
1111 "dependencies" : {
12- "probot" : " ^11 .0.5 "
12+ "@ probot/adapter-aws-lambda-serverless " : " ^2 .0.0 "
1313 },
1414 "repository" : " https://github.com/probot/example-aws-lambda-serverless" ,
1515 "keywords" : [],
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ const assert = require("uvu/assert");
44const nock = require ( "nock" ) ;
55nock . disableNetConnect ( ) ;
66
7- const { Probot, ProbotOctokit } = require ( "probot" ) ;
7+ const {
8+ Probot,
9+ ProbotOctokit,
10+ } = require ( "@probot/adapter-aws-lambda-serverless" ) ;
811
912const app = require ( "./app" ) ;
1013
You can’t perform that action at this time.
0 commit comments