/express-sse

Simple Express Server Sent Events Middleware (using TypeScript)

Primary LanguageJavaScript

Simple Express Server Sent Events Middleware (using TypeScript)

Example

import express from 'express';
import stream from 'express-sse';

const app = express();

const clockFn = async () => new Date(Date.now()).toLocaleTimeString();
app.use('/clock', stream('clock', clockFn));

app.listen(8080, () => {
  console.log('listening on port 8080');
});