Skip to content

Commit b4df732

Browse files
committed
Merge branch 'add-an-update-note-api' into add-a-delete-note-api
2 parents 3ecb6f0 + 8dcbca8 commit b4df732

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

create.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import uuid from "uuid";
22
import * as dynamoDbLib from "./libs/dynamodb-lib";
33
import { success, failure } from "./libs/response-lib";
44

5-
export async function main(event, context, callback) {
5+
export async function main(event, context) {
66
const data = JSON.parse(event.body);
77
const params = {
88
TableName: "notes",
@@ -17,8 +17,8 @@ export async function main(event, context, callback) {
1717

1818
try {
1919
await dynamoDbLib.call("put", params);
20-
callback(null, success(params.Item));
20+
return success(params.Item);
2121
} catch (e) {
22-
callback(null, failure({ status: false }));
22+
return failure({ status: false });
2323
}
2424
}

get.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as dynamoDbLib from "./libs/dynamodb-lib";
22
import { success, failure } from "./libs/response-lib";
33

4-
export async function main(event, context, callback) {
4+
export async function main(event, context) {
55
const params = {
66
TableName: "notes",
77
// 'Key' defines the partition key and sort key of the item to be retrieved
@@ -17,11 +17,11 @@ export async function main(event, context, callback) {
1717
const result = await dynamoDbLib.call("get", params);
1818
if (result.Item) {
1919
// Return the retrieved item
20-
callback(null, success(result.Item));
20+
return success(result.Item);
2121
} else {
22-
callback(null, failure({ status: false, error: "Item not found." }));
22+
return failure({ status: false, error: "Item not found." });
2323
}
2424
} catch (e) {
25-
callback(null, failure({ status: false }));
25+
return failure({ status: false });
2626
}
2727
}

list.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as dynamoDbLib from "./libs/dynamodb-lib";
22
import { success, failure } from "./libs/response-lib";
33

4-
export async function main(event, context, callback) {
4+
export async function main(event, context) {
55
const params = {
66
TableName: "notes",
77
// 'KeyConditionExpression' defines the condition for the query
@@ -19,8 +19,8 @@ export async function main(event, context, callback) {
1919
try {
2020
const result = await dynamoDbLib.call("query", params);
2121
// Return the matching list of items in response body
22-
callback(null, success(result.Items));
22+
return success(result.Items);
2323
} catch (e) {
24-
callback(null, failure({ status: false }));
24+
return failure({ status: false });
2525
}
2626
}

update.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as dynamoDbLib from "./libs/dynamodb-lib";
22
import { success, failure } from "./libs/response-lib";
33

4-
export async function main(event, context, callback) {
4+
export async function main(event, context) {
55
const data = JSON.parse(event.body);
66
const params = {
77
TableName: "notes",
@@ -24,8 +24,8 @@ export async function main(event, context, callback) {
2424

2525
try {
2626
const result = await dynamoDbLib.call("update", params);
27-
callback(null, success({ status: true }));
27+
return success({ status: true });
2828
} catch (e) {
29-
callback(null, failure({ status: false }));
29+
return failure({ status: false });
3030
}
3131
}

0 commit comments

Comments
 (0)