This is an example written in Javascript (Node.js) of a simple text field that can be edited by multiple clients.
- It exposes a single resource:
example.shared
. - It allows setting the resource's
message
property through theset
method. - It resets the model on server restart.
- It serves a web client at http://localhost:8082
- Have NATS Server and Resgate running
- Have node.js installed
Run the following commands:
npm install
npm start
Open the client
http://localhost:8082
Realtime updates
Run the client in two separate tabs, edit the message in one tab, and observe realtime updates in both.
Resources can be retrieved using ordinary HTTP GET requests, and methods can be called using HTTP POST requests.
GET http://localhost:8080/api/example/shared
POST http://localhost:8080/api/example/shared/set
Body
{ "message": "Updated through HTTP" }