A proxy server using server-sent-events (sse) to push data to any number of streaming clients subscribed to a topic (using one-directional communication).
This server accepts post requests sent to localhost:3000/topics/any_topic
and publishes them to any client listening to a streaming topic at localhost:3000/topics/any_topic
.
- Express + Node
- ejs for templating
- cors
- Download the repo & run
npm i
- Run
node server.js
- Go to
localhost:3000/topics/any_topic
on several different browser tabs, replacingany_topic
with whatever topic you want to listen to - Open up a terminal, and send a Post request to the server by running:
curl -X POST -s http:https://localhost:3000/topics/any_topic -H "Content-Type: application/json" -d '{"key": "enter a key here", "value": "some value here"}'
and replaceany_topic
and the key-value pair as you please. (You can also use Postman instead to send this Post request) - See the new record append in all the browsers subscribed to that topic.
- The Express server is contained in
server.js
- The client is contained in
views/client.ejs
(including JS)