Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@steelbreeze/broker

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steelbreeze/broker - npm Package Compare versions

Comparing version 1.0.0-beta.11 to 1.0.0-beta.12

2

lib/client.js

@@ -11,3 +11,3 @@ "use strict";

var http = __importStar(require("http"));
var EventSource = require('eventsource'); // TODO: determine how to TypeScript import this module
var EventSource = require('eventsource');
/**

@@ -14,0 +14,0 @@ * Creates a client to the message broker, providing publish and subscribe operations.

@@ -11,3 +11,5 @@ "use strict";

if (topic.data) {
res.write("id:" + topic.lastEventId + "\ndata:" + topic.data + "\n\n");
setImmediate(function (res, lastEventId, data) {
res.write("id:" + lastEventId + "\ndata:" + data + "\n\n");
}, res, topic.lastEventId, topic.data);
}

@@ -36,3 +38,3 @@ }

res.set({ 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive' });
// update the client with the last message if available
// update the client with the last message if required
if (cacheLastMessage) {

@@ -44,2 +46,3 @@ sendEvent(res, topic);

var body = [];
// read the post body
req.on('data', function (chunk) {

@@ -52,8 +55,5 @@ body.push(chunk);

// queue dispatch of event to all current subscribers
setImmediate(function (topic) {
for (var _i = 0, _a = topic.subscribers; _i < _a.length; _i++) {
var subscriber = _a[_i];
sendEvent(subscriber, topic);
}
}, topic);
topic.subscribers.forEach(function (subscriber) {
sendEvent(subscriber, topic);
});
});

@@ -60,0 +60,0 @@ // send response to publisher

{
"name": "@steelbreeze/broker",
"version": "1.0.0-beta.11",
"version": "1.0.0-beta.12",
"description": "Lightweight publish and subscribe using Server-Sent Events for node and express",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import * as http from 'http';
const EventSource = require('eventsource'); // TODO: determine how to TypeScript import this module
const EventSource = require('eventsource');

@@ -4,0 +4,0 @@ /** Specifies the location of a message broker server. */

@@ -23,3 +23,5 @@ import { Router, Request, Response } from 'express';

if (topic.data) {
res.write(`id:${topic.lastEventId}\ndata:${topic.data}\n\n`);
setImmediate((res: Response, lastEventId: number, data: string) => {
res.write(`id:${lastEventId}\ndata:${data}\n\n`);
}, res, topic.lastEventId, topic.data);
}

@@ -53,3 +55,3 @@ }

// update the client with the last message if available
// update the client with the last message if required
if (cacheLastMessage) {

@@ -62,2 +64,3 @@ sendEvent(res, topic);

// read the post body
req.on('data', (chunk: Buffer): void => {

@@ -71,7 +74,5 @@ body.push(chunk);

// queue dispatch of event to all current subscribers
setImmediate((topic: Topic) => {
for (var subscriber of topic.subscribers) {
sendEvent(subscriber, topic);
}
}, topic);
topic.subscribers.forEach((subscriber) => {
sendEvent(subscriber, topic);
});
});

@@ -78,0 +79,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc