- [Instructor] The shopper sample application
that comes with this course,
is an express application that represents
the shopping system with, an item management,
a shopping page, a shopping basket,
user management and also order management.
All the boilerplate code
as well as the express routes are in place already
so that we can focus on implementing
the database functionality.
As we work through this course
we will use MongoDB, Redis and MySQL
for different aspects of this project
and learn about their individual strengths.
Where it's applicable, we will also use dedicated libraries
that are built on top of the basic database drivers
we are using in Maxcoin.
So if we look into the package.json file of shopper
we see that we have these express dependencies
that we need express itself.
We use some express-session management.
We use cookies.
We rely also on the body-parser for the forms.
And we use Pug as a templating engine.
At devDependencies we have, again everything related
to ESlint and Prettier.
And we also install Nodemon.
Nodemon is a little tool
that you can use to run a node-jest application
and that will then vote for file changes
and will restart the application whenever there is a change.
This means with Nodemon you don't have to constantly restart
the applications while you code.
To use Nodemon I define a script dev
which uses Nodemon and runs server bin/start
which is the starting file for our application.
I think I did not mention it before
that we also have an ESlintrc.json.
So that's in here for shopper but it's also in Maxcoin.
In this file contains the configuration for ESlint
so it says that we are using the AirBnB style guide,
that we are using Prettier,
and it also defines a few more options.
If you're curious about that
just look into the documentation of ESlint.
So to kick this off let's install all the dependencies,
by running npm install, and please make sure
that you are in the shopper directory for that.
So if you were in Maxcoin before,
you would now have to change out of Maxcoin
and into shopper.
There are now run npm install.
And once this is done, I can now run npm run dev
to use Nodemon to start the application.
I see that the application is listening on port 3000
so I can now head over to the browser
and just go to localhost port 3000.
There we end up on a rather basic page
that uses the Bootstrap CSS framework for the basic styling
but it contains everything that a basic shop would need.
So if we click at shop,
okay there is not anything in there
because then we will have the item list later.
If I click on manage users, I already have a form
that can be then used to create users.
If I click on manage items, I see a simple form
where I can create an item with an SKU, a name
and the price.
And I also have a manager order page
which is empty now because there are no orders right now.
And first let's see how this application starts up.
So I go into server bin, start.js
and in there you see pretty much the basic setup
of an express application, and it's pretty similar
to what you would get when you used to express generator.
I load a config file in this config file right now
I'm just defining the application name.
And this application file is the name defined
in the package.json file.
So let's go back, start.js
and everything else should look rather familiar
if you know express.
So it has some error handling in there
and in the end it will call listen to start the server.
To display the pages I already defined routes.
So if we look into server routes
we have an index.js file in there.
And there you see that I'm using express router
so express router can be used to create
kind of stand alone SUP applications
that are used for a specific route.
In there you see we have shop basket,
then we have the administration page like user item
and orders.
If we look into admin and item
and they're into the index file,
we see that a lot is commented out right now
because that's the functionality
that we will later implement.
Most importantly, we will implement
everything that is in our service classes.
So the service classes will hold our business logic
and, here you see we are using item service
and let's look into services, itemsservice
and there you see that it's empty right now.
So this is what we will implement
then during this course using different databases.