(event)
| 65 | } |
| 66 | |
| 67 | const apiGatewayInvocation = async (event) => { |
| 68 | // GET /order |
| 69 | // GET /order/{userName} |
| 70 | let body; |
| 71 | |
| 72 | try { |
| 73 | switch (event.httpMethod) { |
| 74 | case "GET": |
| 75 | if (event.pathParameters != null) { |
| 76 | body = await getOrder(event); |
| 77 | } else { |
| 78 | body = await getAllOrders(); |
| 79 | } |
| 80 | break; |
| 81 | default: |
| 82 | throw new Error(`Unsupported route: "${event.httpMethod}"`); |
| 83 | } |
| 84 | |
| 85 | console.log(body); |
| 86 | return { |
| 87 | statusCode: 200, |
| 88 | body: JSON.stringify({ |
| 89 | message: `Successfully finished operation: "${event.httpMethod}"`, |
| 90 | body: body |
| 91 | }) |
| 92 | }; |
| 93 | } |
| 94 | catch(e) { |
| 95 | console.error(e); |
| 96 | return { |
| 97 | statusCode: 500, |
| 98 | body: JSON.stringify({ |
| 99 | message: "Failed to perform operation.", |
| 100 | errorMsg: e.message, |
| 101 | errorStack: e.stack, |
| 102 | }) |
| 103 | }; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | const getOrder = async (event) => { |
| 108 | console.log("getOrder"); |
no test coverage detected