From 3bc2a7948888687ea6efcf23545f556f1aca873c Mon Sep 17 00:00:00 2001 From: darwin Date: Wed, 15 Jan 2025 15:50:16 -0500 Subject: [PATCH] retriggering --- .../fdr-deploy/getdocs-lambda/src/index.ts | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/servers/fdr-deploy/getdocs-lambda/src/index.ts b/servers/fdr-deploy/getdocs-lambda/src/index.ts index 022d4d19a2..fd65e226ec 100644 --- a/servers/fdr-deploy/getdocs-lambda/src/index.ts +++ b/servers/fdr-deploy/getdocs-lambda/src/index.ts @@ -33,7 +33,7 @@ async function getRedisClient() { }); await redisClient.connect(); - console.log("Connected to Redis"); + // console.log("Connected to Redis"); return redisClient; } finally { isConnecting = false; @@ -110,14 +110,19 @@ export const handler: APIGatewayProxyHandler = async (event) => { try { const redis = await getRedisClient(); - const keys = await redis.keys("*"); - console.log("All Redis keys:", keys); - //dummy commit + if (!redis) { + return { + statusCode: 400, + body: JSON.stringify({ error: "Redis client not found" }), + }; + } + // const keys = await redis.keys("*"); + // console.log("All Redis keys:", keys); const cachedResponse = await redis.get(parsedUrl.getFullUrl()); if (cachedResponse != null) { - console.log(`Cache HIT for ${url}`); - console.log(cachedResponse); + // console.log(`Cache HIT for ${url}`); + // console.log(cachedResponse); const parsedResponse = JSON.parse(cachedResponse); const filesV2 = Object.fromEntries( @@ -152,8 +157,8 @@ export const handler: APIGatewayProxyHandler = async (event) => { }), }; } else { - console.log(`Cache MISS for ${url}`); - console.log("Connecting to RDS"); + // console.log(`Cache MISS for ${url}`); + // console.log("Connecting to RDS"); // second - try to get from rds db try { @@ -167,7 +172,7 @@ export const handler: APIGatewayProxyHandler = async (event) => { }); await client.connect(); - console.log("Connected to RDS"); + // console.log("Connected to RDS"); const query = ` SELECT url, docsDefinition @@ -176,7 +181,7 @@ export const handler: APIGatewayProxyHandler = async (event) => { `; const result = await client.query(query, [parsedUrl]); - console.log("result", result); + // console.log("result", result); if (result.rows.length === 0) { return { @@ -185,8 +190,8 @@ export const handler: APIGatewayProxyHandler = async (event) => { }; } - console.log("found result"); - console.log(result.rows[0]); + // console.log("found result") + return { statusCode: 200, body: JSON.stringify(result.rows[0]),