@steelbreeze/broker
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -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); |
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17163
298