Skip to content

Commit

Permalink
feat: trigger audit from sqs message
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea committed Oct 12, 2023
1 parent 50fb2bb commit 3efeef5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 3efeef5

Please sign in to comment.