ssestream-no-cache-transform
ssestream-no-cache-transform
npm i ssestream-no-cache-transform
ssestream-no-cache-transform

ssestream-no-cache-transform

Send Server-Sent Events with a stream

by EventSource

1.0.1-no-transform (see all)License:MITTypeScript:Not Found
npm i ssestream-no-cache-transform
Readme

Note this is a direct fork of node-SseStream. It just changes the header that the server uses for caching.

More info on this change:

The header 'Cache-Control': 'no-transform' is needed for proxies that interfere with the request (such as caching). This was the case with the create-react-app, when proxying requests to the dev-server backend to your real backend. See this issue: https://github.com/facebook/create-react-app/issues/1633#issuecomment-291353470 . Maybe this header isn't always desired, but I didn't know a good way to make this configurable other than passing a 3rd argument to this pipe function, or maybe an extra parameter to the constructor allowing users to overwrite some of these headers if they want.

SseStream

A node stream for writing Server-Sent Events

Installation

npm install ssestream-no-cache-transform

Or:

yarn add ssestream-no-cache-transform

Usage

In a (req, res) handler for a request event, Express #get route or similar:

const SseStream = require('ssestream-no-cache-transform')

function (req, res) {
  const sse = new SseStream(req)
  sse.pipe(res)

  const message = {
    data: 'hello\nworld',
  }
  sse.write(message)
}

Properties on message:

  • data (String or object, which gets turned into JSON)
  • event
  • id
  • retry
  • comment

Downloads/wk

3

GitHub Stars

24

LAST COMMIT

3yrs ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

2

OPEN PRs

2
VersionTagPublished
1.0.1-no-transform
latest
4yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate