- [Instructor] To use the sample apps
provided with this course,
we have to set them up first.
While we are doing this,
I will also explain the basic structure.
Let's start with the Maxcoin app.
Already opened the folder with our sample apps
that we just fit from GitHub
and amount the development branch the features created.
Maxcoin is an application
that should fetch the daily ending course
of Bitcoin over the last five years from an API
write it to our database of choice
and then query the maximum ending course from it.
We will use MongoDB, Redis and MySQL to do the same task.
But doing so you should get a good feeling
about the differences between these technologies.
So let's open the Maxcoin folder
and you see that we have a main.js.
So this is our main file.
This is what we run.
And there you see that we are requiring a class CoinAPI.
Let's look into CoinAPI.
CoinAPI is rather simple.
It has a fetch method down here
on line 20 and there it creates a URL theory
with the start and end date and then it uses axios,
that's an HTTP library to fetch the data from this URL
and then in the end it returns the response data.
Everything else, so this format date is just the helper
that helps us to get the proper date format
for the URL theory.
Back in main.js, we see that we are using promises here
because in the CoinAPI class we're using async wait.
So we call run, which calls the CoinAPI fetch method
and then we console log the results from it.
And if there is an error we use catch
and console log the error.
Let's look into package.json to see the dependencies
of this application.
So for the regular dependencies, we only need axios
but you also see that we have a lot of dev dependencies.
They are all somehow relate to ESLint and Prettier.
Prettier and ESLint are the tools that help you
to maintain a consistent code style
and avoid common coding mistakes.
So let's install the dependencies first.
For that I opened the integrated terminal, phew terminal.
And in there, I first change into the Maxcoin directory.
Don't forget that that's important.
And then I run NPM installed.
So this will then fetch all the dependencies that we have.
We can now already try this out.
You see that I define the start script that just
runs main.js so I can run NPM start.
And as you see, I get the full list
of ending courses over the last five years as output here.
So this works now
but to integrate ESLint and Prettier seamlessly
into Visual Studio Code
we also have to install two extensions
for Visual Studio Code.
For that click on the left menu bar on the last icon.
This is the Extensions page of Visual Studio Code.
And there, I first look for Prettier
and I just use this first result
this esbenp.Prettier-vscode and I click install.
Next, I also want to install the ESLint extension
and it's by Dirk Baeumer and I just click on install.
Next, I also want to make sure
that this code formatting is applied whenever I save a file.
For that, I open Code, Preferences, Settings
and in Settings as look for format via the search bar.
And then you have this Format On Save conflict option
and you see it's selected here already.
So if it's not selected in your case just check this box.
With that, it should now always apply these formatting rules
when we save a file.
Let's see if this works.
So I go into main.js
and let's change the indentation in line four
at an additional tab and let's save that
and you see the Prettier applies the formatting rules
to defaults that we installed
via the dev dependencies in package.json
Also let's see if ESLint works.
So ESLint will look for common coding mistakes
and one common coding mistake
is that we are defining variables that are never used.
For instance, if I add an argument
to the run function called test
you now see that it's underlined in red.
And when I hover over it,
I see that the test is declared, but never used.
If this is of course, something that we want to avoid
and ESLint helps us with that.
Of course, there are a lot more rules.
So while we are going through this course
you will see all the time that ESLint is complaining
about something it's a little bit nagging sometimes
but again it really helps
to maintain a consistent code style
and avoid common mistakes.
With that done the Maxcoin application
is now ready for action
and we will extend it during the rest of this course.