So in this lesson, we're going to be setting up Jason's server and running it locally, so this gives
us an opportunity to run our own Jason database locally and also interact with it with the various methods
to access the resources, modify the resources, get content from the endpoint.
So this is going to be simulating an endpoint on the server.
And typically, if we do have the data within a database, the server, the backend code is going to
get that content from the database server and output it with an adjacent format and then with the JSON
format, which is being simulated here, we can connect to it from our front end code by making a request
to the endpoint.
So that's going to be coming up in the next lesson.
This lesson is all about installing node, setting up the node package manager, installing the JSON
server and then also running the Jackson server database so it can be ready for the next lesson when
we interact with the content.
For the upcoming lessons, you are going to have to install node as we're going to be using a node package
and running node as are back in code, connecting to it and simulating connection to the server and
also to a database and database content node is available at Node J.S. dot org and then you can download
the node version for your system.
So they've got a version for Windows Mac and just the source code for Linux and also for the different
bit versions.
So this is the 32 bit and the 64 bit that can be downloaded for Windows.
So once you download and install node, you're going to have node on your system.
And in order to interact with node, this is going to be done with the terminal where we're going to
be accessing the file system on the computer.
And for a Mac, you can open up your terminal by pressing the command plus space and that will open
up the spotlight.
And then within the spotlight, you can search for terminal, open up the terminal and you're going
to have to navigate to where your file directory is.
I've created a separate folder I've just given in the name of node.
And that folder is where I've got the indexed HTML file and the OP's JS file.
You can list out the files within your directory with less on a Windows machine.
It's Diar.
So for directory to list out the folders that are currently within your directory.
And the rest of the commands are going to be the same for Windows as well as for Max.
And again, I am using a Mac for windows so you can open up the command.
Terminal and there's also some additional terminals that can be downloaded, so there's open source
terminals that you can install on windows in order to access your file system.
So once you have node installed, you can check and make sure that you do have node by typing a node
dashkova and you should get a version being returned back.
So this is the current version that I have installed on my system to type in node DSV and that will
install.
And so, you know which version you have.
Also, we are using node package manager.
So this comes as part of node when you're installing it and downloading it.
In case it didn't, you can go over to ENPI IMGs and install that separately.
And in order to make sure that NPN is installed, you do NPM Dashkova and that will return back the
node package manager version that you have installed on your system.
So as long as you're getting versions being returned back for node and for package manager, you're
going to be ready to move on to the next part where we're going to do the installation of the package.
So the package that we're going to be installing is the Jackson server and it's available at NPM G.S.
dot com for such a package.
You can also search for the JSON server package.
There's quite a lot of downloads for this package.
That's fairly popular package.
And you can literally set up your rest API in less than 30 seconds.
There's really no coding involved.
As long as you install node and you've got the node package manager ready, you can just do a install
of your JSON server.
So doing an NPN install G and the dash means that this is globally installed and they do have a sample
of debug JSON file so you can create that DB JSON file in order to set up your database.
I got to start out with defaulted JSON file and open up the editor and I'm going to just create this
on the same folder directory that I've got, the indexed HTML and the OP's one JS file.
So just create a new file, paste the data and then this needs to be saved as the debug Jason file.
So go ahead and save that and then we're going to be accessing this with the code.
And also I do have the terminal right now has navigated over to the same folder directory so I can list
out URLs and there's my database file.
So I'm ready to launch the node application and that can be done with Jason Server Watch and then selecting
the file that we want to watch and then we can go to the endpoints for the localhost and get the requests
from there.
So going back into the terminal, we want to launch the deep thought JSON file with the adjacent server.
And if you get this error message command not found, that means that JSON server is not installed.
So you can select the NPM install and globally install the JSON server if you are not able to install
it on a MAC to set the permissions to install as admin.
You can use the pseudo NPM install Daichi JSON server, so that will allow you to do an install as the
administrator.
So if you do throw any security errors or any issues, then you can do that as well.
So it just takes a few seconds and it should install fairly quickly.
And these are the permissions issues that you might encounter.
So this just means that your application doesn't have the right permissions.
So addin UniMac, Adam Souto.
And on a Windows machine, generally, it should run as the administrator as long as the terminal is
being run within the administrator.
So also pseudo NPR install and let's try that one more time.
So it's going to be ask me for my system password.
So type in the system password and now it's going to be installing it as an administrator.
So that will be providing access to the computer file system to do the install.
So now we've got the install done.
I'll clear out the console content and now I should be able to do that JSON server and watch the database
file.
So once we have this up and running and once you've got the Jason server installed, now you can go
to localhost and you can request to the posts.
So also go ahead and try that out and just make sure that you are getting some type of response there.
And if you update the database that Jason.
So if we were to add more posts there and I do a toggle here of the JSON data.
And comma, separate them.
So I'll add in another post just to make sure that we do have the live data and save it, and now when
I refresh it, there's my data that's coming in so I can use this now server as an endpoint to make
connections.
And also within the terminal, they listed out the other options that we have.
So we have four comments and then we also have four profile.
So all of these end points are also driven by what we have here within the main object, so they are
the property names of the objects.
So we can add in additional rights and additional JavaScript, JSON object as needed.
So now when I checked the Roots, I've got a new route here for Testor.
If I want to list out everything that's available there and if I want to select.
So if I want to select the particular posts so I could go to posts and then using whatever the ID is,
this can return back the post.
So this would return back to the second post and this would return back to the first post.
So also within comments, it's going to work the same way.
If I want to return back the first comment, I can do comments.
One, if I try to return back a comment that doesn't exist, I'm just going to get a blank Jason object
being returned back.
So once you have set this up and if you just go to the base, you, Earl, it's going to list out Jason
server information.
So this is just something to keep in mind that it's not listing out the index file.
It's running the Jason server.
And it does list out the resources that we have here.
And we're also able to access it, get post put patched delete options.
So we can modify the resources using any HTTP method.
So going back into index, we're going to open this with live server, so our editor with Life Server
and then make a fetch request to the new endpoints that we've just set up.
So that's coming up in the next lesson.
So this lesson was a set up lesson to set up your local Jason server, customize your database with
some content.
And then next coming up next, we're going to interact with that content.
Thanks for this lesson and before the next lesson is to install node so good over to Node J.S. dot org
and download the version, a node for your system, then open up your system terminal.
So on a Windows machine, you can do the command and UniMac.
You can open up within spotlight and do a search for terminal.
So shortcuts open spotlight is command plus space.
And once you open up the terminal, check to make sure that node is installed, also make sure that
NPM version is installed.
And you can do that by typing node space, Dash V and NPM Space Dashkova, and that will show you the
versions of each one of those.
Create DPE Dot Geass on file locally, add valid JSON data and set up your custom routes if needed.
I would suggest to start with just whatever the default data is available on the server and on their
website and try it out first just to make sure that you get it up and running.
Install the Jason server on your system again using the terminal.
So NPM install Dash G for the global flag and design server for the package that's being installed.
Also, if you do encounter any permissions errors on a Mac, prefix it with the word pseudo and that
will allow you to accept permissions and run with an admin.
And then once you've set it up, run the JSON server package.
And the command for that within the terminal is Jason Jassal and Dash Server see are VR space dash,
dash, watch ATC.
And then space, whatever the file name is, where you've got your JSON data.
So in this case, we're using the default, which is DB, DOT, JSON and also open it up within your
web browser.
So go to localhost Colen three thousand four report three thousand.
And check out the documentation that's available now within your local machine.
And coming up next, you're ready to access those endpoints and then this is all going to be done locally.