1 00:00:00,920 --> 00:00:05,360 In this video we're now going to start to do a little bit of setup using Jason Silver and in Greek so 2 00:00:05,360 --> 00:00:10,390 I've now got those two packages installed into this Jason server directory and I can start up a code 3 00:00:10,400 --> 00:00:17,520 editor inside of here then inside of this new directory I'm going to first begin by creating a D.B. 4 00:00:17,630 --> 00:00:19,560 dot Jason File. 5 00:00:19,560 --> 00:00:24,120 This file is where our Jason server is going to eventually store all of its information. 6 00:00:24,210 --> 00:00:29,010 We have to create this file ahead of time and inside of here we're going to add a little bit of configuration 7 00:00:29,190 --> 00:00:34,020 to tell Jason server about the different types of resources that we wanted to manage. 8 00:00:34,020 --> 00:00:37,540 So to do so I'm going to add in a object inside of here. 9 00:00:37,590 --> 00:00:42,180 This is a Jason File so we're gonna write out some stuff that looks kind of similar to a javascript 10 00:00:42,180 --> 00:00:45,130 object but just as a slightly special syntax. 11 00:00:45,330 --> 00:00:49,620 In particular we just have to make sure that we use double quotes around all the keys that we add in 12 00:00:50,340 --> 00:00:57,150 we're going to add one key in here called blog posts and that's going to be set equal to an empty array 13 00:00:57,210 --> 00:01:03,920 like so so all this does is tell our Jason server that we wanted to create a endpoint for managing a 14 00:01:03,920 --> 00:01:05,940 resource called blog posts. 15 00:01:06,140 --> 00:01:10,250 Over time we're going to see that all the blog posts we create are going to end up as objects inside 16 00:01:10,250 --> 00:01:10,750 this array. 17 00:01:12,190 --> 00:01:15,990 That's pretty much all the configuration we have to do for Jason server. 18 00:01:16,060 --> 00:01:22,370 So now we're going to go over to our package dot Jason File and we're going to add in two scripts to 19 00:01:22,370 --> 00:01:28,100 the script section one script is gonna be dedicated to starting up our Jason server and the other will 20 00:01:28,100 --> 00:01:34,780 be dedicated to starting up and grok so inside of here I'm going to delete the existing script and I'll 21 00:01:34,780 --> 00:01:37,480 replace it with DB you like so. 22 00:01:37,490 --> 00:01:45,400 And anytime we run this DB script I want to run the command Jason server dash w DV dot Jason like so 23 00:01:46,570 --> 00:01:52,340 that's going to be the command that's going to start up our Jason server then we're gonna add in a second 24 00:01:52,340 --> 00:02:02,960 command I'll call it simply tunnel and inside of here we're going to run and grok H each TTP and we're 25 00:02:02,960 --> 00:02:08,100 going to provide some port that we want in grok to connect to on our local machine. 26 00:02:08,150 --> 00:02:12,140 So this is going to essentially be the server that we're going to expose to the outside world so that 27 00:02:12,140 --> 00:02:15,030 we can connect to it from our ReACT native application. 28 00:02:15,110 --> 00:02:18,920 So we want in grok to expose Jace on server by default. 29 00:02:18,920 --> 00:02:23,700 Jason server runs on port three thousand so I'll put it here 3000. 30 00:02:23,720 --> 00:02:29,320 Like so and I'll save this file and we're not going to close this just yet because we might have to 31 00:02:29,320 --> 00:02:33,850 come back here very quickly and make a configuration change going to very quickly test out both these 32 00:02:33,850 --> 00:02:38,050 scripts and you might very quickly see an error appear. 33 00:02:38,050 --> 00:02:43,750 So let's try this out a flip back over to my terminal inside of this Jason server directory. 34 00:02:43,750 --> 00:02:48,730 I'm going to open up two separate terminal windows so we can open up a second one right here. 35 00:02:48,730 --> 00:02:55,000 So I've now got two windows inside of that Jason server directory inside the first one I'll run NPM 36 00:02:55,150 --> 00:02:56,860 run D.B. like so. 37 00:02:57,520 --> 00:03:01,950 So again that's going to start up our Jason server if you see something like this appear. 38 00:03:01,990 --> 00:03:02,470 That's great. 39 00:03:02,470 --> 00:03:04,750 It means that Jason server is up and running. 40 00:03:04,990 --> 00:03:10,360 But if you see a message something that says like air port in use then chances are you already have 41 00:03:10,390 --> 00:03:15,550 another service running on port three thousand on your computer to solve this issue. 42 00:03:15,550 --> 00:03:22,270 You can either close down that other service and rerun the NPM run DB command or alternatively you can 43 00:03:22,270 --> 00:03:28,120 go back to the package dock Jason File that we were just working on right here and on the DV command 44 00:03:28,810 --> 00:03:35,410 you can add on Dash P and put in some different ports to run on like maybe port three thousand one or 45 00:03:35,410 --> 00:03:37,920 two or three or four or whatever. 46 00:03:38,080 --> 00:03:42,520 You only have to do this if you saw an error when you just ran that command. 47 00:03:42,520 --> 00:03:46,540 Now if you do change the port right here you also have to update the port of the tunnel as well. 48 00:03:46,840 --> 00:03:52,950 So if you add on Dash B three thousand five you need to change and grok to three thousand five as well. 49 00:03:53,100 --> 00:03:56,290 For me I did not run into any air when I ran that command. 50 00:03:56,460 --> 00:04:00,500 So I'm not going to make any changes at all. 51 00:04:00,560 --> 00:04:00,800 OK. 52 00:04:00,830 --> 00:04:08,060 So now we can access our Jason server freely on our local machine but no one else in the world can access 53 00:04:08,060 --> 00:04:11,110 our server including your physical phone. 54 00:04:11,270 --> 00:04:14,000 Like I said you can possibly configure your phone. 55 00:04:14,030 --> 00:04:19,370 You can read out your I.P. address of your local machine on your internal Wi-Fi network and essentially 56 00:04:19,370 --> 00:04:22,020 use that from your phone to connect the two. 57 00:04:22,040 --> 00:04:24,320 But like I said that is kind of error prone. 58 00:04:24,320 --> 00:04:28,680 It's incredibly likely that it's not going to work for the vast majority of people watching this course. 59 00:04:29,090 --> 00:04:34,370 So now we're going to instead make use of in grok which is definitely going to make this Jason server 60 00:04:34,580 --> 00:04:39,470 available to the outside world so inside of that second terminal window. 61 00:04:39,820 --> 00:04:46,900 I'm going to run NPM run tunnel like so and that's going to start up a tunnel for us. 62 00:04:47,500 --> 00:04:52,180 So now you're going to see something on here that says forwarding and forwarding this address right 63 00:04:52,180 --> 00:04:57,610 here is going to point directly to a local host 3000 on your local machine. 64 00:04:58,030 --> 00:05:01,600 So you can access this address from any computer on any network. 65 00:05:01,630 --> 00:05:03,980 And it's going to point at your Jason server. 66 00:05:04,120 --> 00:05:07,480 So just approved that right now I'm going to copy that link. 67 00:05:07,660 --> 00:05:11,820 I'm going to go over to my browser open up a new tab and navigate to that address. 68 00:05:11,970 --> 00:05:14,610 And when I do so I can see Jason server up here. 69 00:05:14,620 --> 00:05:17,920 So this is the Jason server I'm running on my local machine. 70 00:05:18,250 --> 00:05:24,600 And you can see there's even a resources section right here that says that I've got a blog post resource. 71 00:05:24,600 --> 00:05:24,820 OK. 72 00:05:24,850 --> 00:05:27,100 So it looks like it's definitely working for me. 73 00:05:27,310 --> 00:05:32,530 Now one thing on it mentioned here is that in grok is only going to run for a very small amount of time 74 00:05:32,530 --> 00:05:34,810 in this case just eight hours. 75 00:05:34,810 --> 00:05:40,030 So every time that you are running your project right now if you run and grok for eight hours at some 76 00:05:40,030 --> 00:05:44,710 point time after eight hours this session is going to expire and you're going to have to restart in 77 00:05:44,710 --> 00:05:50,280 drug so to restart it repress control see and then we can run NPM run tunnel again. 78 00:05:50,770 --> 00:05:54,490 And that's going to give me a brand new session of eight hours again. 79 00:05:54,590 --> 00:06:00,380 Now the one catch here is that when you restart and grok that you Earl is going to be updated. 80 00:06:00,460 --> 00:06:05,060 So you're going to have to make use of that new U.R.L. inside of our ReACT native code. 81 00:06:05,110 --> 00:06:07,970 I'll show you how to do that in just a moment OK. 82 00:06:07,970 --> 00:06:11,960 So now whenever we're going to do development on our application we're going to run three different 83 00:06:11,960 --> 00:06:13,400 terminal windows. 84 00:06:13,430 --> 00:06:15,390 One is for a React Native bundler. 85 00:06:15,410 --> 00:06:21,480 Remember we start that up with NPM run start the second one is inside of our Jason server directory 86 00:06:21,720 --> 00:06:24,150 that's going to be NPM run DB. 87 00:06:24,180 --> 00:06:27,390 And then the third will also be inside of our Jason server directory. 88 00:06:27,420 --> 00:06:33,180 We're going to start that up with NPM run tunnel and NPM run tunnel has to be restarted every eight 89 00:06:33,180 --> 00:06:34,670 hours. 90 00:06:34,700 --> 00:06:35,050 All right. 91 00:06:35,100 --> 00:06:37,040 Now we've got through all this hard stuff. 92 00:06:37,070 --> 00:06:42,170 Let's take a quick pause and we're going to start making use of Jason server all this good stuff in 93 00:06:42,170 --> 00:06:42,860 the next video.