Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaqqaz/wspr
WebSocket proxy for post http requests. Perfect for testing purposes/mocks 🚀
https://github.com/zaqqaz/wspr
http mock post proxy request server test websocket ws
Last synced: 4 days ago
JSON representation
WebSocket proxy for post http requests. Perfect for testing purposes/mocks 🚀
- Host: GitHub
- URL: https://github.com/zaqqaz/wspr
- Owner: zaqqaz
- License: mit
- Created: 2020-07-30T13:58:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T09:35:45.000Z (10 months ago)
- Last Synced: 2024-10-31T12:23:41.447Z (15 days ago)
- Topics: http, mock, post, proxy, request, server, test, websocket, ws
- Language: TypeScript
- Homepage:
- Size: 137 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#)# WSPR
WebSocket proxy for post http requests. Perfect for testing purposes/mocks 🚀![wssExample](https://user-images.githubusercontent.com/2823336/88941927-814ad280-d281-11ea-8624-9637c13ee868.jpg)
### Installation
```
npm i -g wspr
```### Usage
Just run
```
wspr
```after, you will see output with 2 urls:
```
WebSocket server started ws://localhost:3005
HTPP proxy server started http://localhost:3006
```### Broadcast message to clients:
To broadcast a message to clients, send a POST request with a string/JSON body (via Postman or cURL) to the HTTP endpoint provided in the previous step.```
curl -d "{"hello": "world"}" -X POST http://localhost:3006
```### Websocket over secure connection
If you want to run the websocket server over a secure connection, follow these steps:
1. create self signed certificates: https://letsencrypt.org/docs/certificates-for-localhost/#making-and-trusting-your-own-certificates
2. trust the self signed certs, eg on mac: https://tosbourn.com/getting-os-x-to-trust-self-signed-ssl-certificates/
3. pass the paths to the certificate and key using the `--cert` and `--key` CLI args, eg:
```bash
wspr --cert=./localhost.crt --key=./localhost.key
```4. you should see the websocket is now running over wss:
```
WebSocket server started wss://localhost:3005
```
### Proxy and extend existing WebSocketJust specify `--proxyWsUrl='wss://your.url/andPath'` and all the messages from your actual server will be proxied via WSPR with the ability for you to send any extra messages to your clients (useful during new feature implementation when the server has not implemented some messages yet).
## Enjoy 🚀🥤