ssestream-no-cache-transform

1.0.1-no-transform • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ssestream-no-cache-transform

Weekly Downloads

0

Version

1.0.1-no-transform

License

MIT

Unpacked Size

8.21 kB

Total Files

6

Last publish

Collaborators

  • jasoons