# nstomp

> CLI for testing WebSocket with STOMP protocol from terminal.

Latest version **1.2.0** (published 2022-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install nstomp
pnpm add nstomp
yarn add nstomp
bun add nstomp
```

Provides the command `nstomp`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-02-02 |
| First published | 2022-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ilya Novak |
| Maintainers | ilyadev |
| Keywords | STOMP, WebSocket, connection, stomp, stomp 1.2, stomp 1.1, stomp 1.0, CLI, client, stomp-client, terminal-client, test, testing |

## Links

- npm: https://www.npmjs.com/package/nstomp
- Repository: https://github.com/Iluhaprog/nstomp
- Homepage: https://github.com/Iluhaprog/nstomp.git
- Issues: https://github.com/Iluhaprog/nstomp/issues
- npm.io page: https://npm.io/package/nstomp

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^5.0.0
- [commander](https://npm.io/package/commander.md) ^8.3.0
- [websocket](https://npm.io/package/websocket.md) ^1.0.34
- [sockjs-client](https://npm.io/package/sockjs-client.md) ^1.5.2
- [@stomp/stompjs](https://npm.io/package/@stomp/stompjs.md) ^6.1.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-02-02
- 1.1.1 — 2022-02-02
- 1.1.0 — 2022-02-01
- 1.0.1 — 2022-01-31
- 1.0.0 — 2022-01-31
- 0.0.3 — 2022-01-27
- 0.0.2 — 2022-01-27
- 0.0.1 — 2022-01-27

## README

# nstomp
This module is designed to test a websocket connection using the **stomp** protocol;
***nstomp*** allows you to listen to destinations, send messages to them, sending headers when connecting, listening and sending messages is also supported.

#### To install enter
```bash
npm install nstomp --global
```

#### Options

| Option                              | Description                                        |
|-------------------------------------|----------------------------------------------------|
| -v, --version                       |  output the version number                         |
| -u, --url                  |  url where need connect, headers by needed                           |
| -d, --destination  |  destination for subscription or message sending, headers by needed  |
| -m, --message             |  message to send                               |
| -c, --config                 |  path to config file with options |
| -f, --files             | path's to files which need send |
| -sj, --sock-js                      |  enable connection with SockJS.                    |
| -l, --logs                          |  show logs of libraries used in nstomp.            |
| -h, --help                          |  display help for command                          |

#### Options for config file

| Option             | Description                                      | Require | Type   |
|--------------------|--------------------------------------------------|---------|--------|
| url                |  url where need connect                          | ✅   | string |
| connectionHeaders  |  headers for connection                          | ❎    | object |
| destination        |  destination for subscription or message sending | ❎    | string |
| destinationHeaders |  headers for destination                         | ❎    | object |
| message            |  message to send                                 | ❎    | string *or* number *or* object |
| files              |  path's to files which need send                 | ❎    | string[] |
| withSockJS         |  enable connection with SockJS.                  | ❎    | boolean |
| logs               |  show logs of libraries used in nstomp.          | ❎    | boolean |

# Usage example:
## 1. Listening
we need to connect to **http://localhost:3001/stomp**, which requires the **headers**:
```json
{
  "header1": 12,
  "header2": "value2"
}
```
and start listening to the destination **/get**

```bash
nstomp -u http://localhost:3001/stomp '{"header1": 12, "header2": "value2"}' -d /get
```

1. Connect to: **-u** *http://localhost:3001/stomp*
2. Setup connection headers: *'{"header1": 12, "header2": "value2"}'*
3. Setup destination: **-d** */get*

### Config file example:
```json
{
    "url": "http://localhost:3001/stomp",
    "connectionHeaders": {
      "header1": 12,
      "header2": "value2"
    },
    "destination": "/get",
}
```

## 2. Send message
We need send message to destination **/msg** with headers:
```json
{
    "header1": 12,
    "header2": "value2",
}
```
Command example:
```bash
nstomp -u http://localhost:3001/stomp -d /msg '{"header1": 12, "header2": "value2"}' -m '{"message": "hello world", "exp": 123445 }'
```

1. Connect to: **-u** *http://localhost:3001/stomp*
2. Setup destination: **-d** */msg*
3. Headers to send: *'{"header1": 12, "header2": "value2"}'*
4. Message to send  ***[message can be any string]*** : **-m** *'{"message": "hello world", "exp": 123445 }'*

### Config file example:
```json
{
    "url": "http://localhost:3001/stomp",
    "destination": "/msg",
    "destinationHeaders": {
      "header1": 12,
      "header2": "value2"
    },
    "message": {
      "message": "hello world", 
      "exp": 123445
    }
}
```

## 3. Send file
We need send flies to destination **/files** :

files: 
  1. image1.png
  2. image2.jpeg
  3. data.json

```bash
nstomp -u http://localhost:3001/stomp -d /files -f image1.png image2.jpeg data.json
```

1. Connect to: **-u** *http://localhost:3001/stomp*
2. Setup destination: **-d** */get*
3. Setup list of files to send: image1.png image2.jpeg data.json

### Config file example:
```json
{
    "url": "http://localhost:3001/stomp",
    "destination": "/files",
    "files": ["image1.png", "image2.jpeg", "data.json"]
}
```
#### In all examples, of course, there should be your endpoints, addressees, headers and messages

---
_Source: https://npm.io/package/nstomp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
