Socket
Socket
Sign inDemoInstall

nsq-publisher

Package Overview
Dependencies
131
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nsq-publisher

Simple way to create topics and publish messages in NSQ


Version published
Weekly downloads
13
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NSQ Publisher

Build Status Coverage Status Dependency Status

Simple way to create topics and publish messages.

Installation

npm instal --save nsq-publisher

Usage

const Publisher = require('nsq-publisher');


const pub = new Publisher({
  dataUrl: 'localhost', // optional 
  dataHttpPort: 4151, // optional 
  dataTcpPort: 4150, // optional 
  topic: 'test-topic', 
  protocol: 'http', // optional 
  autoCreate: false // optional
});




// pub.createTopic is necessary to make sure that topic exists, 
// but is not necessary if autoCreate is set to true
pub.createTopic(function (err) {
  if (err) {
  	console.error(err);
  } else {
  	console.log('ok');
  }
});
// or
pub.createTopic()
  .then(() => console.log('ok'))
  .catch(err => console.error(err));
  
  
pub.publish('test message', function (err) {
  if (err) {
  	console.error(err);
  } else {
  	console.log('published');
  }
});

// or

pub.publish('test message')
  .then(() => console.log('published'))
  .catch(err => console.error(err));

Keywords

FAQs

Last updated on 25 Apr 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc