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.2 to 1.0.0-beta.3

7

examples/testClient.js

@@ -7,4 +7,8 @@ const broker = require('../lib/index'); // replace with @steelbreeze/broker

// subscribe to the devices topic on the /events broker
client.subscribe('device/1/2/3', (message) => {
console.log(`Device 1/2/3: ${message}`);
});
client.subscribe('devices', (message) => {
console.log(message);
console.log(`All devices: ${message}`);
});

@@ -15,2 +19,3 @@

client.publish('devices', `Hello at ${new Date()}`);
client.publish('device/1/2/3', `Hello at ${new Date()}`);
}, 1000);

8

lib/server.js

@@ -23,4 +23,4 @@ "use strict";

// GET method is used to subscribe by EventSource clients
router.get('/:topic', function (req, res) {
var topic = getTopic(req.params.topic);
router.get('*', function (req, res) {
var topic = getTopic(req.url);
// remove the subscription when the connection closes

@@ -42,3 +42,3 @@ req.on('close', function () {

// POST method publishes a message
router.post('/:topic', function (req, res) {
router.post('*', function (req, res) {
var body = [];

@@ -56,3 +56,3 @@ req.on('data', function (chunk) {

}
}, getTopic(req.params.topic), messageId++, Buffer.concat(body).toString());
}, getTopic(req.url), messageId++, Buffer.concat(body).toString());
// recycle the message id when maxed out

@@ -59,0 +59,0 @@ if (messageId === Number.MAX_VALUE) {

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

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

@@ -31,4 +31,4 @@ import { Router, Request, Response } from 'express';

// GET method is used to subscribe by EventSource clients
router.get('/:topic', (req: Request, res: Response) => {
var topic = getTopic(req.params.topic);
router.get('*', (req: Request, res: Response) => {
var topic = getTopic(req.url);

@@ -55,3 +55,3 @@ // remove the subscription when the connection closes

// POST method publishes a message
router.post('/:topic', (req: Request, res: Response) => {
router.post('*', (req: Request, res: Response) => {
var body: Array<Buffer> = [];

@@ -71,3 +71,3 @@

}
}, getTopic(req.params.topic), messageId++, Buffer.concat(body).toString());
}, getTopic(req.url), messageId++, Buffer.concat(body).toString());

@@ -74,0 +74,0 @@ // recycle the message id when maxed out

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