diff --git a/package-lock.json b/package-lock.json index 68601687..e937d7cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "@aws-sdk/client-dynamodb": "^3.427.0", "@aws-sdk/client-s3": "^3.427.0", "@aws-sdk/lib-dynamodb": "^3.427.0", - "axios": "^1.5.1" + "axios": "^1.5.1", + "esm": "^3.2.25" }, "devDependencies": { "@adobe/eslint-config-helix": "2.0.3", @@ -9998,6 +9999,14 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "engines": { + "node": ">=6" + } + }, "node_modules/esmock": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/esmock/-/esmock-2.5.1.tgz", @@ -28340,6 +28349,11 @@ "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true }, + "esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" + }, "esmock": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/esmock/-/esmock-2.5.1.tgz", diff --git a/package.json b/package.json index 906b3864..72fa7392 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,8 @@ "@aws-sdk/client-dynamodb": "^3.427.0", "@aws-sdk/client-s3": "^3.427.0", "@aws-sdk/lib-dynamodb": "^3.427.0", - "axios": "^1.5.1" + "axios": "1.5.1", + "esm": "3.2.25" }, "devDependencies": { "@adobe/eslint-config-helix": "2.0.3", diff --git a/src/index.js b/src/index.js index 05c027a0..f3f10f9d 100644 --- a/src/index.js +++ b/src/index.js @@ -25,25 +25,25 @@ import PSIClient from './psi-client.js'; // Assuming the exported content of './ async function run(request, context) { const db = DB({ region: process.env.REGION, - accessKeyId: process.env.ACCESS_KEY_ID, - secretAccessKey: process.env.SECRET_ACCESS_KEY, }); + const message = JSON.parse(context.invocation.event.Records[0].body); const psiClient = PSIClient({ apiKey: process.env.PAGESPEED_API_KEY, baseUrl: process.env.PAGESPEED_API_BASE_URL, }); - const auditResult = await psiClient.runAudit('https://www.bamboohr.com/'); const uuid = Date.now().toString(); const site = { id: uuid, - githubURL: 'bamboohr', - domain: 'bamboohr.com', - isLive: '/', - updatedAt: 'edge-delivery', + githubURL: message.githubURL, + domain: message.domain, + path: message.path, + isLive: message.isLive, + updatedAt: uuid, }; await db.saveSite(site); + const auditResult = await psiClient.runAudit(`https://${site.domain}/${site.path}`); await db.saveAuditIndex(site, auditResult); return new Response('SUCCESS'); }