Server-Sent Events is great, but a little tricky to setup and manage with Express.
This package provides a way of managing individual sse connections. In the future a channel subscribe/unsubscribe.
const sse = require('@chriscdn/express-sse-manager/express/')
app.use('/sse', sse.routes)
Add to routes where you'd like access to the sse
connection.
const sseMiddleware = require('@chriscdn/express-sse-manager/express/middleware')
app.use('/myroute/', sseMiddleware, ...)
This adds a sseSendMessage
function to the request.
Connect from the client.