Instructor: So, it's time to start writing some code.
I'm in my terminal, in my project directory
which I've called auth.
I'm gonna create a new file in here, excuse me,
a new folder whose sole job is going to be
to hold our API server.
I'm gonna call it server.
So, I'm gonna make my new directory called server,
and then I'll change into it.
Cool.
Now, the thing that I wanna do on this server
is use absolutely no boiler plate, whatsoever.
So, zero boiler plate.
We're gonna do the entire server from scratch
to make sure that we really understand what's going on
from start to finish.
So, to get started with our from scratch server,
the first thing we'll do is create a package.json file
to hold all of our dependencies for our project.
To create a package.json file,
we'll use the npm init command.
So, I'll run npm init.
This is going to prompt us with a series of questions.
Your answer to these questions don't really matter
at this point or anytime soon.
And so, I'm just gonna go ahead and hit enter
to go through each of them.
That's it.
And, I've now got a package.json file
inside of my server directory.
I'm gonna open my code editor now,
and pull it onto the screen.
And cool.
Here's my working directory server,
and I've got my package.json .
Let's go ahead and install a couple of dependencies
just while we're here.
I'm going to install a couple dependencies.
We'll talk about each of them before we use them,
don't worry.
But it'd be really nice just to install them ahead of time.
So, I'm gonna do npm install dash dash save,
and then we're going to install a couple different ones.
So, don't hit enter just yet.
We're going to get express.
We're going to get Mongoose, two Os on Mongoose.
Let's make this a little bit bigger.
There we go.
We'll get Morgan and one more,
body dash parser, like so.
Okay, so let's install these.
This is gonna take a little bit of time,
so we'll just let it do its thing for now.
Back over in our code editor,
I'm going to now create a new file called index.js
and this is going to be the main starting point of
the application.
So whenever we start our server up,
this is gonna be the main starting point.
This is gonna be the first thing to execute.
Let's check our dependencies out.
Looks like we're good.
We've got everything installed at this point.
By default, if I'm using Git,
node modules directory here is going to attempt to-
I'm going to be able to commit it to my GitHub repo.
I don't ever want to commit my node modules directory,
so I'm gonna create a new file called .gitignore.
And I'm gonna add a line in here that says node modules.
And this just tells Git
'Hey, ignore node modules
whenever you're considering files
to add to my Git repository.'
Okay, so we're back inside of index.js here.
Looking good.
The next thing I wanna do is just try to
start our server up.
Let's just see what happens.
I'm gonna run node index.js .
This is how we're going to run our server.
And nothing happens.
Well, what'd you expect?
We don't have any code yet, right?
Nothing happens just yet,
but just so you know,
we can run our server at any time,
by running node space index.js
and that will start our server up.
So, this is off to a good start so far.
Let's go ahead and continue inside the next section
and add some more code to our project.