In this video we're now going to start to do a little bit of setup using Jason Silver and in Greek so
I've now got those two packages installed into this Jason server directory and I can start up a code
editor inside of here then inside of this new directory I'm going to first begin by creating a D.B.
dot Jason File.
This file is where our Jason server is going to eventually store all of its information.
We have to create this file ahead of time and inside of here we're going to add a little bit of configuration
to tell Jason server about the different types of resources that we wanted to manage.
So to do so I'm going to add in a object inside of here.
This is a Jason File so we're gonna write out some stuff that looks kind of similar to a javascript
object but just as a slightly special syntax.
In particular we just have to make sure that we use double quotes around all the keys that we add in
we're going to add one key in here called blog posts and that's going to be set equal to an empty array
like so so all this does is tell our Jason server that we wanted to create a endpoint for managing a
resource called blog posts.
Over time we're going to see that all the blog posts we create are going to end up as objects inside
this array.
That's pretty much all the configuration we have to do for Jason server.
So now we're going to go over to our package dot Jason File and we're going to add in two scripts to
the script section one script is gonna be dedicated to starting up our Jason server and the other will
be dedicated to starting up and grok so inside of here I'm going to delete the existing script and I'll
replace it with DB you like so.
And anytime we run this DB script I want to run the command Jason server dash w DV dot Jason like so
that's going to be the command that's going to start up our Jason server then we're gonna add in a second
command I'll call it simply tunnel and inside of here we're going to run and grok H each TTP and we're
going to provide some port that we want in grok to connect to on our local machine.
So this is going to essentially be the server that we're going to expose to the outside world so that
we can connect to it from our ReACT native application.
So we want in grok to expose Jace on server by default.
Jason server runs on port three thousand so I'll put it here 3000.
Like so and I'll save this file and we're not going to close this just yet because we might have to
come back here very quickly and make a configuration change going to very quickly test out both these
scripts and you might very quickly see an error appear.
So let's try this out a flip back over to my terminal inside of this Jason server directory.
I'm going to open up two separate terminal windows so we can open up a second one right here.
So I've now got two windows inside of that Jason server directory inside the first one I'll run NPM
run D.B. like so.
So again that's going to start up our Jason server if you see something like this appear.
That's great.
It means that Jason server is up and running.
But if you see a message something that says like air port in use then chances are you already have
another service running on port three thousand on your computer to solve this issue.
You can either close down that other service and rerun the NPM run DB command or alternatively you can
go back to the package dock Jason File that we were just working on right here and on the DV command
you can add on Dash P and put in some different ports to run on like maybe port three thousand one or
two or three or four or whatever.
You only have to do this if you saw an error when you just ran that command.
Now if you do change the port right here you also have to update the port of the tunnel as well.
So if you add on Dash B three thousand five you need to change and grok to three thousand five as well.
For me I did not run into any air when I ran that command.
So I'm not going to make any changes at all.
OK.
So now we can access our Jason server freely on our local machine but no one else in the world can access
our server including your physical phone.
Like I said you can possibly configure your phone.
You can read out your I.P. address of your local machine on your internal Wi-Fi network and essentially
use that from your phone to connect the two.
But like I said that is kind of error prone.
It's incredibly likely that it's not going to work for the vast majority of people watching this course.
So now we're going to instead make use of in grok which is definitely going to make this Jason server
available to the outside world so inside of that second terminal window.
I'm going to run NPM run tunnel like so and that's going to start up a tunnel for us.
So now you're going to see something on here that says forwarding and forwarding this address right
here is going to point directly to a local host 3000 on your local machine.
So you can access this address from any computer on any network.
And it's going to point at your Jason server.
So just approved that right now I'm going to copy that link.
I'm going to go over to my browser open up a new tab and navigate to that address.
And when I do so I can see Jason server up here.
So this is the Jason server I'm running on my local machine.
And you can see there's even a resources section right here that says that I've got a blog post resource.
OK.
So it looks like it's definitely working for me.
Now one thing on it mentioned here is that in grok is only going to run for a very small amount of time
in this case just eight hours.
So every time that you are running your project right now if you run and grok for eight hours at some
point time after eight hours this session is going to expire and you're going to have to restart in
drug so to restart it repress control see and then we can run NPM run tunnel again.
And that's going to give me a brand new session of eight hours again.
Now the one catch here is that when you restart and grok that you Earl is going to be updated.
So you're going to have to make use of that new U.R.L. inside of our ReACT native code.
I'll show you how to do that in just a moment OK.
So now whenever we're going to do development on our application we're going to run three different
terminal windows.
One is for a React Native bundler.
Remember we start that up with NPM run start the second one is inside of our Jason server directory
that's going to be NPM run DB.
And then the third will also be inside of our Jason server directory.
We're going to start that up with NPM run tunnel and NPM run tunnel has to be restarted every eight
hours.
All right.
Now we've got through all this hard stuff.
Let's take a quick pause and we're going to start making use of Jason server all this good stuff in
the next video.