From 635a6394d003e4a4974e1c6b4c74365b8b893f1e Mon Sep 17 00:00:00 2001 From: Robin Baum Date: Sat, 30 Mar 2024 20:27:59 +0100 Subject: [PATCH] Adds missing description for 'doNotWaitForEmptyEventLoop' --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 8f65eed..755d04c 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - [Middlewares](#middlewares) - [`handleCors`](#handlecors) - [`inject`](#inject) + - [`doNotWaitForEmptyEventLoop`](#donotwaitforemptyeventloop) - [`serializeJson`](#serializejson) - [`parseJson`](#parsejson) - [`registerHttpErrorHandler`](#registerhttperrorhandler) @@ -203,6 +204,22 @@ it('should return created user', async () => { }); ``` +### `doNotWaitForEmptyEventLoop` + +Sets `context.callbackWaitsForEmptyEventLoop` to false. + +From [official documentation](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html): +> callbackWaitsForEmptyEventLoop – Set to false to send the response right away when the callback runs, instead of waiting for the Node.js event loop to be empty. If this is false, any outstanding events continue to run during the next invocation. + +```ts +const handler = compose( + types>(), + doNotWaitForEmptyEventLoop(), +)(async (event) => { + +}); +``` + ### `parseJson` `parseJson` is a middleware that parses the request body and extends the event object by a `jsonBody` object: