
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
SSE (Server Sent Events) library for node.js.
sselib is a implementation of the server-side part of the [SSE] 1 protocol written in Coffee Script for the node.js platform.
$ npm install sselib
None, tested on node.js 0.6 >
sselib can be used as a middleware for applications following the Connect convention.
var sselib = require('sselib'),
express = require('express');
var app = express();
app.use(sselib.middleware());
app.get('/events', function(req, res) {
res.sse({
event: 'update',
data: 'I am a stray cat.'
});
});
app.listen(3000);
sselib = require 'sselib'
express = require 'express'
app = express()
app.use sselib.middleware()
app.get '/events', (req, res) ->
res.sse
event: 'update'
data: 'I am a stray cat.'
You can pass options when initializing the middleware.
app.use(sselib.middleware({
retry: 5*1000,
keepAlive: 15*1000,
compatibility: true
});
A already initialized connection can use res.sse.set in order to set a new value for the option. Setting longer retry values and closing connections can be a effective strategy when servers are under high load.
app.get('/events', function(req, res) {
res.sse.set('retry', 30*1000);
});
res.sse.get(option) respectively gets the current configuration.
The time in milliseconds for client reconnects. Default is 5 seconds.
Set to false in order to disable.
Sends pseudo keep alive heartbeats in order to keep the connection open. The value is the amount of milliseconds between each keepAlive heartbeat. Default is 15 seconds.
Set to false in order to disable.
"Quirks mode". Adds support for some polyfills and the way MSIE handles XDomainRequest. Default is true
Set to false in order to disable.
var sselib = require('sselib');
console.log(sselib.event("notice")); // "event: notice\n"
console.log(sselib.data("Hello there!")); // "data: Hello there!\n\n"
// or:
sselib.data("Hello there!", function(err, result) {
if (err) {
// print the error to console
console.log(err);
return;
}
console.log(result) // "data: Hello there!\n\n"
});
Returns a SSE-serialized comment string representing a comment (please note that comments are invisible to browser clients).
Returns a SSE-serialized event string that can be used with a following data type to trigger a event in the browser.
Returns a SSE-serialized id string. If called without id it will use a UNIX timestamp as the id.
Returns a SSE-serialized data string.
message is provided as a meta-serializer. It will return a SSE-serialized string from a message object you pass in.
Returns a Object containing valid HTTP-headers suitable for a http.ServerResponse.
A message object is simply a javascript object containing the data and event keys, it can also optionally be given a id key.
{event: 'update', data: 'I am a stray cat.', id: 789}
BSD (see LICENSE.md)
Made by massförströelse
FAQs
SSE (Server Sent Events) library and middleware.
We found that sselib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.