From 696c749e461d8cac70ee37768996364ed8a25cc1 Mon Sep 17 00:00:00 2001 From: Hamza Mehri Date: Wed, 24 Jan 2024 15:13:54 +0100 Subject: [PATCH] add documentation --- doc/utils/lambda.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/utils/lambda.md diff --git a/doc/utils/lambda.md b/doc/utils/lambda.md new file mode 100644 index 0000000..0d26ab7 --- /dev/null +++ b/doc/utils/lambda.md @@ -0,0 +1,36 @@ +# Lambda + +## Functions + +### `invokeLambdaFunction(input:{functionName: string; payload: object})` + +Invoke a Lambda function. + +Parameters: +- `functionName`: the Lambda function name +- `payload`: the payload/event to send to the Lambda function + +Note: `invokeLambdaFunction` automatically parses the response from the Lambda function and returns either a `string` or an `object` (JSON object) depending on the returned value of the Lambda function: if the Lambda function returns a string, the result will be of type string; if it returns an object, the result will be of type object. + +example: +```typescript +const result1 = await invokeLambdaFunction({ + functionName: 'sum', + payload: { + a: 1, + b: 2, + }, + }); + +console.log(result1) // 3 + +const result2 = await invokeLambdaFunction({ + functionName: 'sum-json', + payload: { + a: 1, + b: 2, + }, + }); + +console.log(result2) // { "result" : 3 } +``` \ No newline at end of file