- [Instructor] In the beginning we decided
that everything related to speakers on the page,
this means listing them and displaying individual entries,
is a good candidate for a microservice of its own.
For that we need to create the new service
and move the respective logic over.
In the exercise files in the provided folder
you'll find a folder speakers-service
that will serve as starting point.
I've copied this folder into a fresh directory
and opened it in Visual Studio Code.
Please note that I'm now using virtual desktops
on my Mac for each of the applications I'm working on
and you'll always see the application
I'm on in the menu bar of Visual Studio Code.
So when I'm switching around,
so that you don't get confused.
Right now I have conference-app, the service-registry,
and the speakers-service open.
Right now the speakers-service is identical
to the scaffold we used for the service registry
except the package name in package.json
is of course different.
Let's first run npm install in the integrated terminal.
And while it's pulling down the dependencies
let's think about which routes
or endpoints will this service need.
Looking at the conference-app
there is a class in server, services, Speakers.
It's a safe bet that we will need a route
for each of the main methods in there.
Of course we could also just create a route
similar to the getData route down there
which then would provide us with all data,
the whole speakers list.
But in real life scenarios this isn't feasible
as soon as the list grows and needs more bandwidth.
So looking at the methods we have in here
I would say we need a route for getList,
one that gets ListShort, one that gets Names,
one for AllArtwork, one getSpeaker
and one getArtworkForSpeaker.
So let's create the routes for that.
So I'm heading back into my speakers-service
and there in server, service.js,
around line 14 I will start implementing.
So I add service.get('/list',
and it's (req, res, next).
And it should return, next('Not implemented').
Now we also want
a list-short that gives us a shorter version of the list.
So I'm just copy-pasting now.
I want a route for the speaker's names
and also another route with a param
that is speaker/:shortname.
That will give me the data for the speaker by its name
and we need something similar for the artwork.
So to fetch the artwork for a given speaker
we create a route /artwork/:shortname.
These are now the routes that we will need.
Let's start the app with npm start.
And I'm opening the browser now.
The application is now listing input 3000
and there I simply call /list.
And I get an error back and if we look into the error log
we see that we get a Not implemented error here.
We will fill the route with logic later,
first we need to register our service
with the service registry on startup.
We will do that in the next video.