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: