Skip to content

Commit 97cf5cb

Browse files
committed
Merge branch 'add-a-delete-note-api' into unit-tests-in-serverless
2 parents cfb1703 + db644a8 commit 97cf5cb

5 files changed

Lines changed: 16 additions & 16 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: process.env.tableName,
@@ -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
}

delete.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: process.env.tableName,
77
// 'Key' defines the partition key and sort key of the item to be removed
@@ -15,8 +15,8 @@ export async function main(event, context, callback) {
1515

1616
try {
1717
const result = await dynamoDbLib.call("delete", params);
18-
callback(null, success({ status: true }));
18+
return success({ status: true });
1919
} catch (e) {
20-
callback(null, failure({ status: false }));
20+
return failure({ status: false });
2121
}
2222
}

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: process.env.tableName,
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: process.env.tableName,
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: process.env.tableName,
@@ -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)