From b8a57338ffa5b1f53d609fef3d47faa204f64f1a Mon Sep 17 00:00:00 2001 From: alinarublea Date: Wed, 11 Oct 2023 10:53:41 +0200 Subject: [PATCH] merge master --- package.json | 2 +- src/index.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ffd45244..32603416 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "semantic-release": "semantic-release", "semantic-release-dry": "semantic-release --dry-run --no-ci --branches $CIRCLE_BRANCH", "build": "hedy -v --test-bundle", - "deploy": "hedy -v --deploy --test", + "deploy": "hedy -v --deploy --test --aws-region=us-east-1", "deploy-routes": "hedy --no-build -no-hints -l major", "deploy-ci": "hedy -v --deploy --test --pkgVersion=ci$CIRCLE_BUILD_NUM -l ci --cleanup-ci=24h", "deploy-secrets": "hedy --aws-update-secrets --params-file=secrets/secrets.env", diff --git a/src/index.js b/src/index.js index 8283d86b..d363c7d9 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,9 @@ import secrets from '@adobe/helix-shared-secrets'; import wrap from '@adobe/helix-shared-wrap'; import { logger } from '@adobe/helix-universal-logger'; import { helixStatus } from '@adobe/helix-status'; -import { Response } from '@adobe/fetch'; + +const DB = require('./db'); +const PSIClient = require('./psi-client'); /** * This is the main function @@ -21,10 +23,14 @@ import { Response } from '@adobe/fetch'; * @param {UniversalContext} context the context of the universal serverless function * @returns {Response} a response */ -function run(request, context) { - const name = new URL(request.url).searchParams.get('name') || process.env.SECRET; - context.log.info(`Saying hello to: ${name}.`); - return new Response(`Hello, ${name}.`); +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 psiClient = PSIClient({ + apiKey: process.env.PAGESPEED_API_KEY, + baseUrl: process.env.PAGESPEED_API_BASE_URL, + }); + const auditResult = await psiClient.runAudit('https://www.bamboohr.com/'); + await db.saveAuditIndex(auditResult); } export const main = wrap(run)