Skip to content

Commit fb0a213

Browse files
DHAMODHARABALAJI RDHAMODHARABALAJI R
authored andcommitted
..
1 parent c31be7c commit fb0a213

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

order-manager/src/handlers/createOrder.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ exports.handler = async (event) => {
2525

2626
// Payload Sample
2727

28-
// {
29-
// "id": "2",
30-
// "items": [
31-
// {
32-
// "id": "1",
33-
// "name": "tv"
34-
// },
35-
// {
36-
// "id": "2",
37-
// "name": "monitor"
38-
// }
39-
// ]
40-
// }
28+
{
29+
"id": "2",
30+
"items": [
31+
{
32+
"id": "1",
33+
"name": "tv"
34+
},
35+
{
36+
"id": "2",
37+
"name": "monitor"
38+
}
39+
]
40+
}
4141

4242

4343
// await setCache(`order:${order.orderId}`, order);

order-manager/src/handlers/getMyOrders.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ const dbContext = require("../utils/dbContext");
22

33
exports.handler = async (event) => {
44

5-
const body = await dbContext.Orders().Scan();
5+
const items = await dbContext.Orders().Scan();
66

7-
console.log('items: ', body.Items)
7+
console.log('items: ', items)
88

9-
if (!body || !body.Items) return { statusCode: 404, body: "Orders not found" };
9+
if (!items) return { statusCode: 404, body: "Orders not found" };
1010

1111
return {
1212
statusCode: 200,
13-
body: JSON.stringify(body.Items),
13+
body: JSON.stringify(items),
1414
};
1515
};

order-manager/template.yaml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,34 @@ Resources:
113113
Method: get
114114
RestApiId: !Ref OrderApi
115115

116-
GetOrderFunction:
117-
Type: AWS::Serverless::Function
118-
Properties:
119-
CodeUri: src/
120-
Handler: handlers/getOrder.handler
121-
Runtime: nodejs22.x
122-
MemorySize: 128
123-
Timeout: 10
124-
Policies:
125-
- DynamoDBCrudPolicy:
126-
TableName:
127-
!Ref DynamoDBOrdersTable
128-
- AWSLambdaVPCAccessExecutionRole
129-
- AmazonDynamoDBFullAccess
130-
- AWSLambdaSQSQueueExecutionRole
131-
- AWSLambdaBasicExecutionRole
132-
- AWSSecretsManagerGetSecretValuePolicy:
133-
SecretArn: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:mongodb/credentials-*"
134-
Environment:
135-
Variables:
136-
HOSTING_ENV: !Ref HOSTINGENV
137-
Events:
138-
ApiEvent:
139-
Type: Api
140-
Properties:
141-
Path: /orders/{id}
142-
Method: get
143-
RestApiId: !Ref OrderApi
116+
GetOrderFunction:
117+
Type: AWS::Serverless::Function
118+
Properties:
119+
CodeUri: src/
120+
Handler: handlers/getOrder.handler
121+
Runtime: nodejs22.x
122+
MemorySize: 128
123+
Timeout: 10
124+
Policies:
125+
- DynamoDBCrudPolicy:
126+
TableName:
127+
!Ref DynamoDBOrdersTable
128+
- AWSLambdaVPCAccessExecutionRole
129+
- AmazonDynamoDBFullAccess
130+
- AWSLambdaSQSQueueExecutionRole
131+
- AWSLambdaBasicExecutionRole
132+
- AWSSecretsManagerGetSecretValuePolicy:
133+
SecretArn: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:mongodb/credentials-*"
134+
Environment:
135+
Variables:
136+
HOSTING_ENV: !Ref HOSTINGENV
137+
Events:
138+
ApiEvent:
139+
Type: Api
140+
Properties:
141+
Path: /orders/{id}
142+
Method: get
143+
RestApiId: !Ref OrderApi
144144

145145
Outputs:
146146
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function

0 commit comments

Comments
 (0)