Package Exports
- lambda-stream
- lambda-stream/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lambda-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Lambda-Stream
This library adds types and local support for AWS Lambda Response Streaming. Locally, it'll buffer and return the entire response.
In AWS Lambda, it'll simply use the global awslambda.streamifyResponse
.
This library exposes a ResponseStream
class, the streamifyResponse
method, and isInAWS
method.
Works like this:
import { APIGatewayProxyEvent } from "aws-lambda";
import { streamifyResponse, ResponseStream } from 'lambda-stream'
export const handler = streamifyResponse(myHandler)
async function myHandler (event: APIGatewayProxyEvent, responseStream: ResponseStream): Promise<void> {
console.log('Handler got event:', event)
responseStream.setContentType("text/plain");
responseStream.write("Hello, world!");
responseStream.end();
}
Or in commonjs:
'use strict';
const { streamifyResponse } = require('lambda-stream')
module.exports.hello = streamifyResponse(
async (event, responseStream, context) => {
responseStream.setContentType("text/plain");
responseStream.write("Hello, world!");
responseStream.end();
}
);