In the last video we discussed the pros and cons of option number three.
So this is the option that we're going to go with.
There's a lot of changes we need to make in several locations to implement this entire flow so we need
to make changes to the comment service and the query service.
We also need to create the moderation service.
I think we should get started by creating the moderation service for right now.
It's a good place to get started.
We're just going to worry about putting together a little bit of boilerplate for the project in this
video and in the next video we'll start to add in all these additional events and add in some code to
handle them as well.
So let's get to it.
We're going to create this new moderation service to get started.
I'm gonna flip back over to my terminal.
I'm going to open up yet another terminal window which I've already got right here inside my blog.
Project directory and inside there I'll make a new folder called moderation I'll then change into that
directory.
I'm going to maximize this terminal window really quick as you can see this very easily.
All the other terminal windows are still running.
I'm just using a hotkey to maximize that 1 window inside of you're going to generate a new package JS
on file with NPM in it Dash y and then as we've done several times before we're going to install a couple
of dependencies so I'm going to get access express node Mohn.
And in this case we do not need cause because we are not going to have our front end application make
any direct request to this moderation service.
So the course module not required this time around so I'm going to install that stuff and after that's
all done.
There we go.
I'm going to pop that kernel window back into this tile.
We're not going to start up the server just yet.
Let's go and write a little bit of code and I'll come back over and start up that additional service
so I can go to my editor here's the new moderation directory inside there I'll make a new file called
index dot J.S. and then at the very top let's add in some different require statements so I'm gonna
get express
I'm gonna get body parser
and I'll get access
then once again create a new express application and wire up the body parser middleware.
So I'll make sure I call Jason as a function all right.
So what does this service really need to do.
Well all this service does is watch for events.
It's just gonna watch for that event we mentioned so common created whenever we see come and created
the moderation service is going to need to emit the comment moderated event.
So we really just need all we need inside this thing is one root handler just a single root handler
for that slash events end point that we already set up previously inside of comments query and our post
service as well.
So inside of here we're going to add an app dot post or events will then take our rec and rez like so
we'll come back to that root handler in just a moment.
First let's make sure that our app actually starts listening on some port now at this point in time.
We've got several different ports in use so as a reminder we've got four thousand four posts 1001 for
comments or thousand to four.
What is this.
The query service and we'll use 4000 in three for moderation.
So we will do an app.
Listen four thousand three and inside of you I'll do a console log listening on four thousand three
okay.
Before putting together any implementation on this host event and post root handler right there let's
set up our package not just on file with the script and just make sure that we can run this thing successfully
at our terminal.
Here's my package that Jason File I will delete that existing test script and replace it with a start
and we'll do the Woodman index dot J.S.
Okay that looks pretty good let's go and run this project so I'll go back over my terminal once again
I'm going to find that terminal window that's going to be in charge of running our moderation service
there it is right there and inside there I'll do NPM start okay there we go.
So we've now got many different services running for our application.
Definitely.
Hey you know this is of course about micros services.
So yeah we're going to create a lot of services just understand how to create them all and get them
all working together.
Look it looks like that is running on port four thousand three and we've got a good start to this moderation
service.
Let's take a quick pause right here.
When come back next video we're going to start to add in some implementation for the events handler
right here and make sure that any time we see an event of type comment created we do some moderation
on it.
And then eventually emit this comment.
Moderated event in turn.
So a quick pause.
Take care that just a moment.