New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.3 to 1.0.0-beta.4

lib/client.d.ts

3

package.json
{
"name": "@steelbreeze/broker",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "Lightweight publish and subscribe using Server-Sent Events for node and express",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {

@@ -7,0 +8,0 @@ "test": "mocha"

# broker
Lightweight publish and subscribe using Server-Sent Events for node and express
If you like broker, please star it...
## Install
```shell
npm i @steelbreeze/broker
```
## Usage
### Server
To create a message broker server within an express application:
```javascript
const express = require('express');
const broker = require('@steelbreeze/broker');
// create the express application
var app = express();
// create a message broker server and bind it to the /events base URL
app.use('/events', broker.server({lastMessage: true}));
// start the express application
app.listen(1024, 'localhost');
```
You can create multiple message broker servers and bind them to different base URLs.
### Subscriber
To create a subscription:
```javascript
const broker = require('@steelbreeze/broker');
// create a client to the message broker
var client = broker.client({host:'localhost', port: 1024, path: '/events'});
// subscribe to the devices topic on the /events broker
client.subscribe('devices', (message) => {
console.log(`devices: ${message}`);
});
A single client can subscribe to multiple topics.
```
### Publisher
To create a subscription:
```javascript
const broker = require('@steelbreeze/broker');
// create a client to the message broker
var client = broker.client({host:'localhost', port: 1024, path: '/events'});
// publish a message on the devices topic of the /events broker every second
setInterval( () => {
client.publish('devices', `Hello devices at ${new Date()}`);
}, 1000);
```
## License
MIT License
Copyright (c) 2018 David Mesquita-Morris

@@ -10,3 +10,3 @@ {

// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */

@@ -13,0 +13,0 @@ // "sourceMap": true, /* Generates corresponding '.map' file. */

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