Skip to content

Commit

Permalink
DO-1610: roll back queue message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Feb 1, 2024
1 parent 982e755 commit d6a8e71
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, SQSEvent } from "aws-lambda";
import { Context, SQSEvent, SQSRecord } from "aws-lambda";
import axios from "axios";

const userAgent = "prerender / Googlebot recaching request";
Expand All @@ -9,17 +9,13 @@ const userAgent = "prerender / Googlebot recaching request";
* @param context - The AWS Lambda context object.
*/
export const handler = async (event: SQSEvent, _context: Context) => {
// Only one item in the message is assumed.
const url = event.Records[0].body;
console.log(`Fetching ${url} for recaching`);
const res = await axios.get(url, {
headers: {
"User-Agent": userAgent,
},
event.Records.forEach(async (record: SQSRecord) => {
const url = record.body;
console.log(`Fetching ${url} for recaching`);
await axios.get(url, {
headers: {
"User-Agent": userAgent,
},
});
});
console.log(
`Requested ${url} recaching, got ${JSON.stringify(
res.status
)}, response headers: ${JSON.stringify(res.headers)}`
);
};

0 comments on commit d6a8e71

Please sign in to comment.