Consuming a service
In this recipe, we are going to create a application layer that will consume our microservice. This is the API and client tier in our reference architecture depicted in the figure in the introduction to the chapter.
We will be using the Express web framework to do this and also the Generator to create an application skeleton.
Note
Express
For an introduction to Express see the Creating an Express Web App recipe in Chapter 7, Working with Web Frameworks.
Getting ready
This recipe builds on the code from our last recipe, Creating a simple RESTful microservice. We'll be using the micro
folder from the previous recipe as a starting point.
Let's install the express-generator
, which we'll be using to rapidly generate Express scaffolding, and the standard
linter (and formatter) that we'll use to reformat the generated code the lint rules use in this book.
To do this, run:
$ npm install -g express-generator standard
Now, let's build our web app.
How to do it...
First let's open a terminal...