A hello world example that illustrate microservice chaining / proxying
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Hello Service (microservice chaining)

Build Status Carbon Version

This example illustrates microservice chaining / proxying where one microservice uses another microservice as part of its implementation.

This package defined two services:

  • PublicHelloService: which defines a simple /hello endpoint that delegates to our PrivateHelloService
  • PrivateHelloService: which defines a simple /hello endpoint that returns { msg: "Hello world!" }


Client                       PublicHelloService                 PrivateHelloService
  |        GET /hello            
  | ---------------------------> /hello
                                    |           GET /hello
                                    | -----------------------------> /hello
                                        200: { msg: "Hello world!" }   |
      200: { msg: "Hello world!" }  |

Installing the service

We encourage you to clone the git repository so you can play around with the code.

$ git clone -b carbon-0.7 git@github.com:carbon-io-examples/example__hello-world-service-chaining.git
$ cd example__hello-world-service-chaining
$ npm install

Running the services

Start the private service:

$ node lib/PrivateHelloService

Start the public service (order does not matter):

$ node lib/PublicHelloService

For cmdline help:

$ node lib/PublicHelloService -h


$ node lib/PrivateHelloService -h

Accessing the service

To access the /hello endpoint on the public service:

$ curl localhost:8888/hello
{ msg: "Hello world!" }

Running the unit tests

This example comes with a simple unit test written in Carbon.io's test framework called TestTube. It is located in the test directory.

$ node test/HelloServiceTest


$ npm test

Generating API documentation (aglio flavor)

To generate documentation using aglio, install it as a devDependency:

$ npm install -D --no-optional aglio

Using --no-optional speeds up aglio's install time significantly. Then generate the docs using these commands:

$ node lib/PrivateHelloService gen-static-docs --flavor aglio --out docs/private-api.html
$ node lib/PublicHelloService gen-static-docs --flavor aglio --out docs/public-api.html

View current documentation