00:07
this series, we're ready to go ahead and create our first AdonisJS 6 project. So in order to do this, we're going to need to jump into our terminal. So let's go ahead and open that up.
00:16
Now for all of my code based projects, I like to put them all inside of a folder called code. So I'm going to CD into that folder. If you have a place that you like to put your code on your computer, go ahead and head into that directory.
00:26
If you don't, maybe consider creating a folder called code. You can create a folder by doing make dir or mkdir and then provide in the folder names. That'd be something like code.
00:36
And then after you run that command, you could then CD into code to jump into that folder like we are right here. I'm already within a folder called code, so I'm going to bypass running that command there
00:45
and I'm going to clear my terminal out. So now let's actually create our project. So we're going to need to run a command against npm. So we'll do npm init and the command is called AdonisJS.
00:55
And we'll want to target the latest version of that. And this command is going to walk us through the process of actually creating our Adonis JS project. But before we actually run this command, we're going to want to provide it a project name.
01:04
I'm going to call mine let's learn AdonisJS 6. Now we're ready to go ahead and hit enter to run it. It's going to ask us which starter kit we would like to use. And it has three options.
01:14
We have the slim starter kit, the web starter kit, and the API starter kit. Now back in our first lesson, we talked about batteries that AdonisJS can come with.
01:21
These starter kits determine how many batteries we get included and what type of batteries we get included for the particular purpose that we select.
01:29
For example, if we were to select the slim starter kit, it would come with the bare bone number of batteries that we would need to actually get our server up and running.
01:36
We could always add additional batteries on top of it once we start with that slim starter kit, but it's going to be the leanest option that we have to get started with AdonisJS.
01:44
The web starter kit is going to include everything that we need to start up a web server. This is going to include things like session support, the edge template engine, and so on and so forth.
01:52
And then the API starter kit is going to contain things you need to create an API where you have your client side application or what's running the browser completely separated from your AdonisJS project.
02:02
So depending on what you need for your particular project, you'll want to select the appropriate starter kit for that. For us, that's going to be the web starter kit. So let's go ahead and select the web starter kit here.
02:11
It's going to ask us whether or not we want to install our dependencies. It's going to use NPM to do so. Whenever you installed Node.js, NPM installed alongside of that. The two go hand in hand with one another.
02:20
So we're a-okay to go ahead and have it install our dependencies for us. These dependencies are going to be all of the different packages from AdonisJS and other package creators to actually run our underlying server.
02:30
So these are things AdonisJS created themselves, as well as packages that they rely on to get to the underlying Adonis server. So let's go ahead and install those.
02:39
So it's going to install those packages like it's doing right now, and it's going to prepare our application, which it already has done. And now it's configuring AdonisJS Lucid. And now it's done.
02:48
So let's go ahead and scroll back up a little bit and finish running through what exactly it did. So first it downloaded the web starter kit from their GitHub repository. The starter kit is essentially all of the code that we're going to start with whenever
02:58
we actually dive into our code base. So if we were to compare our starter code with the web starter kit that they have on their repository, it would be a match.
03:06
Then it's going to install the packages specifically for that web starter kit, since we told it to right up here. Then it's going to start preparing our application, and to do so it's going to install and configure
03:16
Lucid. And as a result, it's going to have it set to the SQLite database. Now as we covered in our last lesson, we're going to be using Postgres as our database driver.
03:24
However, whatever database driver you use doesn't really matter too much because Lucid is going to abstract that away for the most part.
03:29
So if you already have SQLite installed, or if you have MySQL or MSSQL, that's a-okay. You can go ahead and use those drivers. Whenever we install our Postgres driver for Lucid, just go ahead and select the driver
03:39
that you need. If you're using SQLite, then you're already set. And if none of that made sense, don't worry, we're going to walk through it. And then lastly, it's going to configure authentication, and it's going to specifically
03:48
do so with the session guard. The session guard essentially is just going to use browser sessions in order to maintain the statefulness of our authentication. Cool.
03:57
So all of those different actions get us down to our starting AdonisJS project. So we can go ahead and CD into our project now by running CD.
04:06
Let's learn AdonisJS 6. We can run npm run dev to actually boot the server up. So let's do npm run dev, and there we go.
04:15
So now our server address is ready at 127.0.0.1 colon 3333.
04:21
The HTTP 127.0.0.1 is our hostname, and then the colon separates our hostname from the port. 3333 is then our port.
04:29
The 127.0.0.1 specifies that the server's running on our machine, and then the port is kind of like the street address.
04:36
It's the specific address on our machine that the server's running. So if we go ahead and open this particular address up in our browser, we can command or
04:43
control click directly on this, and it will open it up within our browser just like so, and we'll see it works.
04:49
Now in other places, you may also see 127.0.0.1 replaced with localhost.
04:55
Localhost is just a human-friendly string that means 127.0.0.1, so they are interchangeable. So if we go ahead and hit enter here, you see we get the exact same thing. Cool.
05:05
So let's go ahead and hide our browser away here for a second, and let's finish walking through what this command states. So you'll see it also mentions that the file system watcher is enabled.
05:13
Essentially, the AdonisJS server has started in development mode, and since it knows that it's in development mode, it knows that we're going to make frequent changes to it.
05:21
To help us out with that, it's going to watch our file system for those changes, and whenever it recognizes any of those changes, it will automatically apply it to our running server
05:29
so that we can just see it immediately within our browser, which is pretty nice and convenient. All right, so now let's go ahead and open up our project within our text editor. So here's Visual Studio Code.
05:38
We can go ahead and hit open here. Let's head into the directory that we installed our application within. So mine's within code. I'm going to want to scroll down a little bit to the Let's Learn AdonisJS 6.
05:48
Just select the folder right here, and then hit open. That's going to open up all of the files and folders that we have within that folder that make up our project.