Title: Helper method for headers and status code · Issue #9 · astuyve/lambda-stream · GitHub
Open Graph Title: Helper method for headers and status code · Issue #9 · astuyve/lambda-stream
X Title: Helper method for headers and status code · Issue #9 · astuyve/lambda-stream
Description: As per the readme update, users can add headers and a status code to their streaming responses using a built-in helper method like so: const { streamifyResponse } = require('lambda-stream') const stream = require('stream') module.exports...
Open Graph Description: As per the readme update, users can add headers and a status code to their streaming responses using a built-in helper method like so: const { streamifyResponse } = require('lambda-stream') const s...
X Description: As per the readme update, users can add headers and a status code to their streaming responses using a built-in helper method like so: const { streamifyResponse } = require('lambda-stream')...
Opengraph URL: https://github.com/astuyve/lambda-stream/issues/9
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Helper method for headers and status code","articleBody":"As per the [readme update](https://github.com/astuyve/lambda-stream#headers-status-code), users can add headers and a status code to their streaming responses using a built-in helper method like so:\r\n\r\n```\r\nconst { streamifyResponse } = require('lambda-stream')\r\nconst stream = require('stream')\r\nmodule.exports.hello = streamifyResponse(\r\n async (event, responseStream, context) =\u003e {\r\n const metadata = {\r\n statusCode: 200,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n \"CustomHeader\": \"outerspace\"\r\n }\r\n };\r\n \r\n // Use global helper to pass metadata and status code\r\n responseStream = awslambda.HttpResponseStream.from(responseStream, metadata);\r\n\r\n responseStream.write(\"Streaming with Helper \\n\");\r\n await new Promise(r =\u003e setTimeout(r, 1000));\r\n responseStream.write(\"Hello 0 \\n\");\r\n await new Promise(r =\u003e setTimeout(r, 1000));\r\n responseStream.write(\"Hello 1 \\n\");\r\n await new Promise(r =\u003e setTimeout(r, 1000));\r\n responseStream.write(\"Hello 3 \\n\");\r\n responseStream.end();\r\n // Suggested in Documentation: https://docs.aws.amazon.com/lambda/latest/dg/response-streaming-tutorial.html\r\n // But NOT defined in node 16 or node 18\r\n // Only defined in node 14\r\n await responseStream.finished();\r\n }\r\n);\r\n```\r\n\r\n\r\nWould library users support shimming this method locally?\r\nShould we consider wrapping this in Lambda as well? We could simply always return a ResponseStream with helper support. It seems to be a no-op if an empty object is passed as the `metadata` argument.\r\n\r\nThoughts?","author":{"url":"https://github.com/astuyve","@type":"Person","name":"astuyve"},"datePublished":"2023-08-08T16:06:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/9/lambda-stream/issues/9"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8993b5d0-95a4-0d91-aaff-c38f07acd2f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9250:2A09C:57100D:6FB9BB:6991309B |
| html-safe-nonce | ce085d09663692d4a2c81f447fa8ea3adc45fba5d33275ccbc01a0a0b66933a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjUwOjJBMDlDOjU3MTAwRDo2RkI5QkI6Njk5MTMwOUIiLCJ2aXNpdG9yX2lkIjoiMjE3NjA2MzkwODM0NjkzMzQwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 61e691382e53badab88ff5ab4878667cec95741aa80f09a98285932cb267dc5b |
| hovercard-subject-tag | issue:1841599506 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/astuyve/lambda-stream/9/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e43e62248cb02bcb97098fd09c93ae08f37547abbf82fb99d327370cd24e496/astuyve/lambda-stream/issues/9 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e43e62248cb02bcb97098fd09c93ae08f37547abbf82fb99d327370cd24e496/astuyve/lambda-stream/issues/9 |
| og:image:alt | As per the readme update, users can add headers and a status code to their streaming responses using a built-in helper method like so: const { streamifyResponse } = require('lambda-stream') const s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | astuyve |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/astuyve/lambda-stream git https://github.com/astuyve/lambda-stream.git |
| octolytics-dimension-user_id | 1598537 |
| octolytics-dimension-user_login | astuyve |
| octolytics-dimension-repository_id | 632476278 |
| octolytics-dimension-repository_nwo | astuyve/lambda-stream |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 632476278 |
| octolytics-dimension-repository_network_root_nwo | astuyve/lambda-stream |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width