1.0.0 • Published 6 years ago

pubnub-spy v1.0.0

Weekly downloads
2
License
unlicense
Repository
-
Last release
6 years ago

pubnub-spy 🕵️‍♂️🕵️‍♀️

A simple tool to subscribe to and read pubnub messages from given channels. This is intended to help with development to keep an eye on what messages are being sent via a given channel, and also let you push your own messages onto a channel.

Usage

Usage: pubnub-spy [options]


Options:

  -e, --environment <environment>     Select your PubNub
  
  -s, --spy <channel> [channels...]   Read from the PubNub channel(s)
  
  -p, --push <message>                Publish a single message to a channel
  
  -h, --help                          output usage information
  

Configuring pubnub-spy for your PubNub apps:

The first thing to do when setting up pubnub-spy is to set up the configuration. By default, the app contains an empty file called config.json. Within this, the Config is prepopulated with three environments. You can choose whether or not to keep these, but you can also append further environments.

The name of the environment you wish to target are passed in with the -e flag when either spying on a channel, or pushing a message onto one.

In order to use pubnub-spy, you need to set up at least one environment. Just add your publish and subscribe keys to the environment you wish to configure, these keys can be found on the PubNub dashboard of your apps. Then you're ready to go.

Using PubNub Spy

Note: All requests require the -e flag. This denotes which which PubNub environment you wish to target. This is configured in the config.json file (see above).

Spying on a channel

In the terminal run:

pubnub-spy -e [ENVIRONMENT_NAME] -s [CHANNEL_NAME(S)] 

This works with one or many channels. For example:

pubnub-spy -e prod -s testChannel1

or

pubnub-spy -e prod -s testChannel1 testChannel2 testChannel3 [...]

You will see the messages flowing through these channels printed to your console.

Pushing a message onto a channel

In the terminal run:

pubnub-spy -e [ENVIRONMENT_NAME] -p "message"

For example:

pubnub-spy -e prod -p "testMessage"

When you enter the command, you will be prompted for the channel which this message will be pushed to. Pressing enter on this will attempt to push the message and the outcome will be printed to the terminal (success or fail).

You can only push a message onto one channel at a time.