From bc5a6772b757024600536c21192126964155c880 Mon Sep 17 00:00:00 2001 From: KrishnaSolo Date: Wed, 21 Apr 2021 19:15:24 -0400 Subject: [PATCH 1/2] Updated post and put for notes to use singular note - was missed earlier for some reason --- takeNotes-src/postNote/app.js | 4 ++-- takeNotes-src/putNotes/app.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/takeNotes-src/postNote/app.js b/takeNotes-src/postNote/app.js index a0ad370..15e1c5e 100644 --- a/takeNotes-src/postNote/app.js +++ b/takeNotes-src/postNote/app.js @@ -32,14 +32,14 @@ function isValidRequest(context, event) { event.pathParameters.id !== null; let body = event.body; - let isBodyValid = body !== null && body.notes !== null; + let isBodyValid = body !== null && body.note !== null; return isIdValid && isBodyValid; } function updateRecord(recordId, eventBody, id) { let d = new Date(); - console.log("record id: " + recordId + " eventBody: " + eventBody.notes); + console.log("record id: " + recordId + " eventBody: " + eventBody.note); let noteBody = eventBody.note; const metaFields = { diff --git a/takeNotes-src/putNotes/app.js b/takeNotes-src/putNotes/app.js index 78e7785..a560d8c 100644 --- a/takeNotes-src/putNotes/app.js +++ b/takeNotes-src/putNotes/app.js @@ -39,7 +39,7 @@ function isValidRequest(context, event) { function updateRecord(recordId, eventBody, noteIdx) { let d = new Date(); - console.log("record id: " + recordId + " eventBody: " + eventBody.notes); + console.log("record id: ", recordId, " eventBody: ", eventBody.note); const params = { TableName: TABLE_NAME, Key: { @@ -49,12 +49,12 @@ function updateRecord(recordId, eventBody, noteIdx) { ExpressionAttributeNames: { "#noteId": noteIdx }, ExpressionAttributeValues: { ":u": d.toISOString(), - ":n": eventBody.notes, + ":n": eventBody.note, }, ConditionExpression: "attribute_exists(docBody.notes.#noteId)", ReturnValues: "ALL_NEW", }; - console.log("params: " + params); + console.log("params: ", params); return docClient.update(params); } From f3ba9f143214259ed6eac93a3a8f373abc038359 Mon Sep 17 00:00:00 2001 From: KrishnaSolo Date: Wed, 21 Apr 2021 19:16:48 -0400 Subject: [PATCH 2/2] fixed up logging to be better - will need to apply this to other lambdas at some point --- takeNotes-src/postNote/app.js | 7 +++---- takeNotes-src/putNotes/app.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/takeNotes-src/postNote/app.js b/takeNotes-src/postNote/app.js index 15e1c5e..45b0572 100644 --- a/takeNotes-src/postNote/app.js +++ b/takeNotes-src/postNote/app.js @@ -39,7 +39,7 @@ function isValidRequest(context, event) { function updateRecord(recordId, eventBody, id) { let d = new Date(); - console.log("record id: " + recordId + " eventBody: " + eventBody.note); + console.log("record id: ", recordId, " eventBody: ", eventBody.note); let noteBody = eventBody.note; const metaFields = { @@ -63,14 +63,13 @@ function updateRecord(recordId, eventBody, id) { ConditionExpression: "attribute_not_exists(docBody.notes.#noteId)", ReturnValues: "ALL_NEW", }; - console.log("params: " + params); + console.log("params: ", params); return docClient.update(params); } // Lambda Handler exports.postNote = async (event, context, callback) => { - console.log("event: " + event); - console.log("body: " + event.body); + console.log("event: ", event); if (!isValidRequest(context, event)) { return response(400, { message: "Error: Invalid request" }); } diff --git a/takeNotes-src/putNotes/app.js b/takeNotes-src/putNotes/app.js index a560d8c..13f40ce 100644 --- a/takeNotes-src/putNotes/app.js +++ b/takeNotes-src/putNotes/app.js @@ -60,8 +60,8 @@ function updateRecord(recordId, eventBody, noteIdx) { // Lambda Handler exports.putNotes = async (event, context, callback) => { - console.log("event: " + event); - console.log("body: " + event.body); + console.log("event: ", event); + console.log("body: ", event.body); if (!isValidRequest(context, event)) { return response(400, { message: "Error: Invalid request" }); }