Examples
Service and client examples written in different languagesNote
In order to run the examples, you must have installed NATS Server and Resgate, listening on their default ports.
All examples are complete with both service and client.
NodeJS
The resgate repository contains examples written for NodeJS. These examples use the nats client directly, without the use of any extra library. That makes them perfect to use in combination with the Writing Services guide.
Running an example
Run the following commands, but change hello-world
to the example you wish to try:
git clone https://github.com/resgateio/resgate.git
cd resgate/examples/hello-world
npm install
npm start
The output tells you the local URL for the web client.
Example | Description |
---|---|
hello-world | Simple service serving a static message. |
edit-text | Text field that can be edited by multiple clients concurrently. |
book-collection | List of book titles & authors that can be edited by many. |
jwt-authentication | Showing how JWT tokens can be used for authentication. |
password-authentication | Showing authentication with user and password credentials. |
client-session | Creating client sessions that survive reloads and reconnects. |
Go
The go-res repository contains examples written for Go.
Running an example
Run the following commands, but change 01-hello-world
to the example you wish to try:
git clone https://github.com/jirenius/go-res.git
cd go-res/examples/01-hello-world
go run .
The output tells you the local URL for the web client.
Example | Description |
---|---|
Hello World | Smallest of services serving a static message. |
Edit Text | Single text field that is updated in real time. |
Book Collection | List of book titles & authors that can be edited by many. |
Book Collection Store | Book Collection example persisting changes using BadgerBD store. |
Search Query | Make live queries against a large customer database. |
C#
The .NET ResgateIO.Service repository contains examples written for C#.
Running an example
Clone the repository:
git clone https://github.com/jirenius/csharp-res
Open one of the solutions, found in examples\
, in Visual Studio 2017.
Check the example’s README.md file for more details.
Example | Description |
---|---|
Hello World | Smallest of services serving a static message. |
Edit Text | Single text field that is updated in real time. |
Book Collection | List of book titles & authors that can be edited by many. |
Search | Make live queries against a large customer database. |
Identity Server 4
A stand-alone example shows how to integrate Resgate with Identity Server 4:
GitHub - Identity Server 4 authentication for Resgate
Javascript (Browser)
The resclient repository contains examples that focus on how to use ResClient for different reactive frontend frameworks.
Running an example
Run the following commands, but change book-collection-react
to the example you wish to try:
git clone https://github.com/resgateio/resclient.git
cd resclient/examples/book-collection-react
npm install
npm start
The output tells you the local URL for the web client.
Example | Description |
---|---|
book-collection-react | React client implementation of the Book Collection example. |
book-collection-vuejs | Vue.js client implementation of the Book Collection example. |