- [Instructor] Now it's time to add a bit of logic
to service registry.
When designing services, I always start
with the actions a service should eventually perform.
In a REST based service,
those actions are represented by routes.
So let's sketch out the routes that we will need.
First we need a route the service can use
to register itself.
And the service should be characterized by a name,
a version, and a port it can be found in.
So, for that I'm opening server, service.js,
and somewhere here on there after line 13,
I start adding service,
and this should be a put request, htp put.
and the route should be /register
then we have argument servicename
and
next we have an argument
serviceversion
and the last argument is
serviceport
note the double columns here,
those are parameters that contain
dynamic route parameters.
Then we have
the regular callback
request response next
and in there for now we just
return next
not implemented.
we also want to be able to delete services,
and that is basically the same route,
but now with the htp route delete.
Of course we also need a way to find the registered service
so I add for that and then again,
copy over what I had before,
and this will be a get route and it will be
find servicename, serviceversion,
and of course we don't want to clear the serviceport.
This should then return a service with this name,
and a given version.
Next we need some infrastructure to actually store
and manage the registered services,
we will build that next.