Inless video we spoke about the flow that a user will go through as they are creating a survey.
We're now going to talk a little bit about some of the different routes that we're going to set up on
our express server to allow users to create surveys get a list of them and so on.
So let's talk about all those different routes.
Now as we start building all this survey stuff I can definitely tell you that a lot of the backend stuff
that we're going to do is going to be a lot of moving pieces.
Let's put it that way.
I'm not going to say that it's going to be crazy complicated because I think a lot of the code that
we're going to write will be fairly straightforward but there's going to be a lot of different parts
of the puzzle so to speak kind of moving around to make sure that these emails get sent out.
So we're going to do our best to make sure that we kind of isolate one route to work on at a given time.
We will test it until we are really sure that it's worked in the way we expect and I'll move on to the
next one after we finish all three of these routes.
We will then move on to the front end of our application and build out the front end to make sure that
it matches these back end routes we put together.
Okay.
So let's talk about these three routes that we're going to create.
We'll start off with the easiest one up at top so this will be a GET request to API slash service when
the user makes a request to this route really straightforward find all of the surveys that the current
user has created.
And remember when I say current user right here I'm talking about the user who issued this request.
So we'll find all the surveys that they have created and we will return them back to them.
So you can imagine that this first route right here is really all about making sure that we can show
a list of all the surveys that the user has created and the different feedback that they have received
for each one.
Now we're going to skip the second one for just a second and move on to the third one down here.
So the third one will be a POST request to API slash service.
The purpose of this handler will be to handle the case in which a user wants to create a new survey
and have it automatically be e-mailed out to everyone they want.
Now whenever someone makes a POST request to this route we are going to expect that they send along
four different pieces of data with a POST request.
The first is going to be a title property.
Now the title is going to be the title of the survey.
In other words the name for the survey that the user will see when they are in our application.
You might think that the title versus the subject line of the email should be the same but really you
might want to call a title of a survey something like March 22 survey results or something like that
something that has meaning to you as our user and you might not want that to be reflected as the exact
same subject of email which is actually sent out to your end users.
OK.
So we're going have a title which will be kind of the internal name of the survey.
We will have a subject which will be the subject line to show in the email we will have a body property
which will be the text to show in the actual email which will essentially be this text right here right
in the center.
We were hoping you could tell us if you enjoyed our service blah blah blah you know all this kind of
stuff.
So this would be the body of the survey right here.
The actual text to show in the email to prompt the end user to click on one of the two buttons.
And then finally a recipient's property.
Now this one is definitely the most important property the recipient's property and is going to be a
comma separated list of email addresses.
So this will be the list of addresses to send out the e-mail to.
So in total the POST request route for API surveys all about creating a new survey we're going to require
to have these four different properties.
OK.
Now the very last one.
All right here in the middle a POST request to API slash surveys slash WebEx.
So this one is going to be a little bit more challenging to understand until we start to really dive
into some of the implementation with the actual email provider that we're going to use.
So the intent of this route right here is to receive feedback from a user and end user who has received
an e-mail and clicked a link in the survey.
So this would be like if I'm an end user I get this e-mail right here and I click yes right here.
That would be me issuing a piece of feedback.
So we're going to somehow report that through this route right here of a POST request to API surveys
slash Web looks.
Now like I said in the last section we are going to use our e-mail provider to record the actual output
of clicking on a yes or no right here.
That's why we've got this kind of name web hooks in here.
We'll talk about what a web hook is later on.
And again there is a very good reason that we're taking this approach.
And once we start getting over to this route you make sure I'll make sure that you've got a much better
sense of exactly why we're doing it this way.
Just take my word for it right now.
We're going to make sure that the e-mail provider is the one to record the actual click and then they
will tell our express server Hey someone clicked blink or no they did not or whatever it might be.
OK.
So that's pretty much it for our different routes.
So let's take a break right now.
When we come back in the next section we're going to start putting together our post for API slash surveys.
So essentially we're going to handle the case in which a user wants to create a new survey.
So quick break and I'll see you in just a minute.