In class video we realize that we're going to have to start working on this API server before we can
really progress forward much further with the form that we are currently working on.
So in this video we're going to start to learn a little bit about how we're going to put together this
API server.
Now remember at the end the last video I had told you that this was going to be pretty easy and straightforward
for the app guys server and it's because we're going to use a little package to help us put it together.
So I'm going to pull open some documentation for a package called Jaison server.
I'm going to copy this link right here.
Open up a new tab and navigate to it.
All right so here's the documentation for JS on server.
When you look at this documentation some of it might seem a little bit familiar.
It might look familiar because this package is what is powering that same API we used earlier on in
the course.
If you remember that Type-I code Jaison placeholder this thing right here.
So we use this and point earlier in the courts this end point this server is using the base on server
package.
So you're kind of already familiar with using this thing.
Now the reason that we are going to use JS on server in particular as opposed to putting something together
from scratch with say Express or something like that is that JS on server has a extremely strict adherence
to something called restful conventions.
Let me tell you a little bit more about what restful conventions are.
Arrest conventions or restful conventions are a predefined system for defining different routes on an
API that work with a given type of records.
That's super unclear.
Even when I say it so let me show you a diagram that's going to explain what this really is.
I want you to think about the different streams that we are trying to create and show and delete and
update inside of our applications.
There's really a set number of ways that you and I are going to work with these streams.
We kind of already discussed this when we were talking about the different components that we are going
to create.
We probably want to have the ability to list all the different streams that have been created inside
of application.
We probably want to have the ability to get details about one stream we probably want to create a stream.
We probably want to be able to update a stream and delete a stream so these actions right here are these
different ways of manipulating a record are all probably the most common ways that we are going to want
to interact with these stream objects that we are trying to create.
So the term restful conventions is essentially referring to a standardized system of routes and request
methods used to commit or operate all these different actions.
So following restful conventions if we want to list all records released all the streams that are stored
on our API server then by convention we will make a get request to a get type HTP request to the route
streams on our API server.
If our API server follows restful conventions then whenever we make a request to slash streams the API
server should return an array of all the different stream objects that it holds.
Now the API server doesn't have to the API server could define this stream's route.
Where they get request as like for some crazy reason.
Deleting all streams.
That's totally possible.
We don't have to define define a API server to behave in any which way we can have it behave in any
way we want.
But in order to make our API is easier to work with for like other engineers we usually try to follow
these restful conventions.
So this is not a hard requirement.
It is highly recommended.
Just to make it easier for other engineers to work with software that you design.
So if we want to list all records we will make a get request to slash streams if we want to get one
particular record.
We'll make a get request to streams slash and then the idea of the stream that we want to retrieve to
create a stream will make a post request request to slash streams.
And if we update a record we'll make a put two streams slash and then the ID and same thing for delete
as well but delete method instead.
So again the reason that we are making use of JS on server is that it very strictly adhered to all these
restful conventions.
If you want to get a list of all the different streams stored by JS on server we are going to make a
request to slash streams and then Jay Sun server it will return a list of any streams that exist inside
the application.
So again the reason we're making these suggestions here as opposed to using something like Express is
just to make sure that you really understand these basic conventions in a re-act application.
And there's no possibility of us wiring up a Express server or something like that in some funky way
that doesn't obey restful conventions.
All right so that's the idea.
So let's take a pause right here.
When we come back the next section we're going to start to set up use on server side of our project
and we'll start to make a couple of test requests over to it just to make sure that it works the way
we expect.
So quick Pozen I'll see you in just a minute.