Skip to content

Commit ef7ca3d

Browse files
authored
Merge pull request #2 from aws-samples/ReadMeFix
2 parents 808878f + 0c2ea8c commit ef7ca3d

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.js
22
!jest.config.js
3+
!load-generation/order-payload-generator.js
34
*.d.ts
45
node_modules
56

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ response to bad data.
1111
- [CDK Toolkit](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html) & bootstrapped AWS environment
1212
- [docker](https://docs.docker.com/engine/install/)
1313
- [mvn](https://maven.apache.org/run.html)
14+
- [Turn on CloudWatch logs for API Gateway REST and WebSocket APIs](https://repost.aws/knowledge-center/api-gateway-cloudwatch-logs)
1415

1516
> **[!IMPORTANT]**
1617
> You need to deploy the stack to an AWS Region where [AWS FIS is supported](https://docs.aws.amazon.com/general/latest/gr/fis.html).
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const uuid = require('uuid');
2+
3+
const PROTECTION_PLAN_TYPES =["SingleDevice", "MultiDevice", "Family"];
4+
const PROTECTION_PLAN_COST = [29, 49, 69];
5+
6+
function getRandomInt(max) {
7+
return Math.floor(Math.random() * max);
8+
}
9+
10+
module.exports = {
11+
12+
generatePayloadData: (userContext, events, done) => {
13+
let randomIndex = getRandomInt(3);
14+
15+
userContext.vars.Id = uuid.v4();
16+
userContext.vars.deviceId = "device123";
17+
userContext.vars.protectionPlanAmount = PROTECTION_PLAN_COST[randomIndex];
18+
userContext.vars.orderAmount = PROTECTION_PLAN_COST[randomIndex];
19+
userContext.vars.protectionPlan = PROTECTION_PLAN_TYPES[randomIndex];
20+
userContext.vars.deviceType ="iphone11";
21+
userContext.vars.customerOrderId = randomIndex;
22+
userContext.vars.customerId = "cust123";
23+
24+
return done();
25+
},
26+
printStatus: (requestParams, response, context, ee, next) => {
27+
28+
console.log(`ENDPOINT: [${response.req.method}] ${response.req.path}: ${response.statusCode}`);
29+
if (response.statusCode >= 400) {
30+
console.warn(response.body);
31+
}
32+
return next();
33+
}
34+
}

0 commit comments

Comments
 (0)