Skip to content

Commit 98c4223

Browse files
Update params names and table
1 parent 8a080c6 commit 98c4223

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/controller/item.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const createItem = async (event: APIGatewayEvent) => {
1313
};
1414

1515
const getItem = async (event: APIGatewayEvent) => {
16-
const itemId = event.pathParameters?.id;
16+
const itemId = event.pathParameters?.itemId;
1717

1818
if (!itemId) {
1919
return createResponse(StatusCodes.BAD_REQUEST, {
@@ -33,7 +33,7 @@ const getAllItems = async () => {
3333
};
3434

3535
const updateItem = async (event: APIGatewayEvent) => {
36-
const itemId = event.pathParameters?.id;
36+
const itemId = event.pathParameters?.itemId;
3737

3838
if (!itemId) {
3939
return createResponse(StatusCodes.BAD_REQUEST, {
@@ -48,7 +48,7 @@ const updateItem = async (event: APIGatewayEvent) => {
4848
};
4949

5050
const deleteItem = async (event: APIGatewayEvent) => {
51-
const itemId = event.pathParameters?.id;
51+
const itemId = event.pathParameters?.itemId;
5252

5353
if (!itemId) {
5454
return createResponse(StatusCodes.BAD_REQUEST, {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const handler = async (
1616
case "POST":
1717
return createItem(event);
1818
case "GET":
19-
if (event.pathParameters) {
19+
if (event.pathParameters?.itemId) {
2020
return getItem(event);
2121
}
2222
return getAllItems();

src/models/item.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ const ddb = new dynamoose.aws.ddb.DynamoDB({
88

99
dynamoose.aws.ddb.set(ddb);
1010

11-
const ItemModel = dynamoose.model("ItemsTable", itemSchema);
11+
const ItemModel = dynamoose.model("items", itemSchema);
1212

1313
export default ItemModel;

src/schemas/item.schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const itemSchema = new dynamoose.Schema({
1616
required: false,
1717
},
1818
createdAt: {
19-
type: Date,
20-
default: () => new Date(),
19+
type: String,
20+
default: () => new Date().toISOString(),
2121
},
2222
});
2323

0 commit comments

Comments
 (0)