From 629d4f11f8f0dbbfcceafa130de47a42cd8ed822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Thu, 6 Jul 2023 13:55:18 +0200 Subject: [PATCH] Reintroduce AWS Lambda adapter --- netlify/functions/validate-pr.ts | 22 ---------------- netlify/functions/validate-pr/index.ts | 14 +++++++++++ netlify/functions/validate-pr/package.json | 4 +++ package-lock.json | 29 ---------------------- package.json | 1 - 5 files changed, 18 insertions(+), 52 deletions(-) delete mode 100644 netlify/functions/validate-pr.ts create mode 100644 netlify/functions/validate-pr/index.ts create mode 100644 netlify/functions/validate-pr/package.json diff --git a/netlify/functions/validate-pr.ts b/netlify/functions/validate-pr.ts deleted file mode 100644 index ac518ba..0000000 --- a/netlify/functions/validate-pr.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Handler, HandlerEvent, HandlerContext } from '@netlify/functions'; -import { createProbot } from 'probot'; - -import { appFn } from '../../appFn'; - -const privateKey = (process.env.PRIVATE_KEY as string).replace(/\\n/gm, '\n'); - -const handler: Handler = async ( - event: HandlerEvent, - context: HandlerContext -) => { - const probot = createProbot({ overrides: { privateKey } }); - - await appFn(probot); - - return { - statusCode: 200, - body: 'Playlist Entry Validator by Maciej Pędzich' - }; -}; - -export { handler }; diff --git a/netlify/functions/validate-pr/index.ts b/netlify/functions/validate-pr/index.ts new file mode 100644 index 0000000..7287734 --- /dev/null +++ b/netlify/functions/validate-pr/index.ts @@ -0,0 +1,14 @@ +import { + createProbot, + createLambdaFunction +} from '@probot/adapter-aws-lambda-serverless'; + +import { appFn } from '../../../appFn'; + +const privateKey = (process.env.PRIVATE_KEY as string).replace(/\\n/gm, '\n'); + +const handler = createLambdaFunction(appFn, { + probot: createProbot({ overrides: { privateKey } }) +}); + +export { handler }; diff --git a/netlify/functions/validate-pr/package.json b/netlify/functions/validate-pr/package.json new file mode 100644 index 0000000..50a2545 --- /dev/null +++ b/netlify/functions/validate-pr/package.json @@ -0,0 +1,4 @@ +{ + "name": "mackorone-playlist-pr-bot", + "version": "1.0.0" +} diff --git a/package-lock.json b/package-lock.json index 0dcefa8..3a829e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@netlify/functions": "github:netlify/functions", "@probot/adapter-aws-lambda-serverless": "^3.0.3", "metadata-scraper": "^0.2.60", "probot": "^12.2.8" @@ -65,17 +64,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@netlify/functions": { - "version": "1.6.0", - "resolved": "git+ssh://git@github.com/netlify/functions.git#3e1d890892fb6f1975ffaf92a78de68253432602", - "license": "MIT", - "dependencies": { - "is-promise": "^4.0.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@octokit/auth-app": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-4.0.5.tgz", @@ -2298,11 +2286,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==" - }, "node_modules/jmespath": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", @@ -3845,13 +3828,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "@netlify/functions": { - "version": "git+ssh://git@github.com/netlify/functions.git#3e1d890892fb6f1975ffaf92a78de68253432602", - "from": "@netlify/functions@github:netlify/functions", - "requires": { - "is-promise": "^4.0.0" - } - }, "@octokit/auth-app": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-4.0.5.tgz", @@ -5698,11 +5674,6 @@ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" }, - "is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==" - }, "jmespath": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", diff --git a/package.json b/package.json index 16ae4ab..77e7fa7 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ }, "homepage": "https://github.com/maciejpedzich/mackorone-playlist-pr-bot#readme", "dependencies": { - "@netlify/functions": "github:netlify/functions", "@probot/adapter-aws-lambda-serverless": "^3.0.3", "metadata-scraper": "^0.2.60", "probot": "^12.2.8"