Giter Site home page Giter Site logo

zaqqaz / wspr Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 140 KB

WebSocket proxy for post http requests. Perfect for testing purposes/mocks ๐Ÿš€

License: MIT License

TypeScript 92.32% JavaScript 7.68%
websocket test mock proxy http ws server post request

wspr's Introduction

styled with prettier PRs Welcome

WSPR

WebSocket proxy for post http requests. Perfect for testing purposes/mocks ๐Ÿš€

wssExample

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:

wspr --cert=./localhost.crt --key=./localhost.key
  1. you should see the websocket is now running over wss:
WebSocket server started wss://localhost:3005

Proxy and extend existing WebSocket

Just 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 ๐Ÿš€๐Ÿฅค

wspr's People

Contributors

billy-reilly avatar dependabot[bot] avatar zaqqaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.