Skip to content

Commit e2dab49

Browse files
committed
readme
1 parent 64a2e9a commit e2dab49

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $ npm i @fastify/aws-lambda
3131
| retainStage | Retain the stage part of the API Gateway URL | `false` |
3232
| pathParameterUsedAsPath | Use a defined pathParameter as path (i.e. `'proxy'`) | `false` |
3333
| parseCommaSeparatedQueryParams | Parse querystring with commas into an array of values. Affects the behavior of the querystring parser with commas while using [Payload Format Version 2.0](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format) | `true` |
34+
| payloadAsStream | If set to true the response is a stream and can be used with `awslambda.streamifyResponse` | `false` |
3435
## 📖Example
3536

3637
### lambda.js
@@ -122,6 +123,27 @@ await app.ready() // needs to be placed after awsLambdaFastify call because of t
122123
*[Here](https://github.com/fastify/aws-lambda-fastify/issues/89) you can find the approriate issue discussing this feature.*
123124

124125

126+
#### Support for response streaming (`payloadAsStream`)
127+
128+
```js
129+
import awsLambdaFastify from '@fastify/aws-lambda'
130+
import { promisify } from 'util'
131+
import stream from 'stream'
132+
import app from './app.js'
133+
134+
const pipeline = promisify(stream.pipeline)
135+
const proxy = awsLambdaFastify(app, { payloadAsStream: true })
136+
export const handler = awslambda.streamifyResponse(async (event, responseStream, context) => {
137+
const { meta, stream } = await proxy(event, context)
138+
responseStream = awslambda.HttpResponseStream.from(responseStream, meta)
139+
await pipeline(stream, responseStream)
140+
})
141+
await app.ready() // https://github.com/fastify/aws-lambda-fastify/issues/89
142+
```
143+
144+
*[Here](https://github.com/fastify/aws-lambda-fastify/issues/154) you can find the approriate issue discussing this feature.*
145+
146+
125147
## ⚡️Some basic performance metrics
126148

127149
**@fastify/aws-lambda (decorateRequest : false)** x **56,892 ops/sec** ±3.73% (79 runs sampled)

0 commit comments

Comments
 (0)