express-server-sent-events

1.1.0 • Public • Published

express-server-sent-events

Express middleware to push events/messages from the server to the browser, using EventSource.

This middleware will keep the request stream open indefinitely, pad the initial response stream for IE and flush the response if the compression middleware is in use.

Detailed information on how to setup the browser/client can be found here.

Difference from original

Use flush instead of flushHeaders

Removed IE padding (let's move on)

Installation

$ npm install express-server-sent-events --save

Usage (with express)

// require sse
var sse = require('express-server-sent-events');
var express = require('express');
 
var app = express();
 
app.get('/events', sse, function(req, res) {
  // res.sse is made available via the middleware
  res.sse('data: im from the server\n\n');
});

Package Sidebar

Install

npm i express-server-sent-events

Weekly Downloads

3

Version

1.1.0

License

MIT

Last publish

Collaborators

  • klemensas