Skip to content

Conversation

@svozza
Copy link
Contributor

@svozza svozza commented Nov 13, 2025

Summary

This PR adds streaming functionality to the public API. Streaming is now used like so:

import {Router, streamify} from '@aws-lambda-powertools/event-handler/experimental-rest';

const app = new Router();

app.get('/event', async ({event}) => {
  return Readable.from(Buffer.from(JSON.stringify(event)))
});

export const handler = streamify(app)

Changes

  • Created streamify function that turns a Router instance into a handler that can return streaming responses.
  • Create a fallback streamifyHandler function that is used when streamify is used in non-lambda environments, which is useful for unit tests.

Testing

  • Moved the logic from parseStreamOutput used by the tests to the fallback streamifyHandler function.
  • Updated all the unit tests to use the streamify function rather than app.resolveStream.
  • Tested in a ambda with a streaming function URL set up.

Issue number: closes #4726


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@svozza svozza self-assigned this Nov 13, 2025
@boring-cyborg boring-cyborg bot added event-handler This item relates to the Event Handler Utility tests PRs that add or change tests labels Nov 13, 2025
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Nov 13, 2025
@svozza svozza requested a review from sdangol November 13, 2025 15:52
@sonarqubecloud
Copy link

@svozza svozza merged commit be4e4e2 into main Nov 13, 2025
45 checks passed
@svozza svozza deleted the event-handler/streamify-util branch November 13, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event-handler This item relates to the Event Handler Utility size/L PRs between 100-499 LOC tests PRs that add or change tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Expose Response Streaming in Event Handler Public API

2 participants