Hey, did everyone.
They sure.
And welcome to another video in the documentation section.
So now we have a full understanding of how the basic documentation works, but it is also equally important
that we do a little bit of more in-depth learning more about the get request per post request.
Grouping them together, maybe having different kind of header requests and a whole bunch of other things
that we are going to talk about.
Now for this, we are going to create a new project and the goal of this project to understand a little
bit more about Express and a little bit more about the documentation in this project.
We won't be separating the files into controllers and the and the routes.
I know a lot of you have already heard about that through my other courses or somewhere else.
We will be doing that very soon.
Not yet.
The focus here is to learn more about documentation.
So we'll be doing exactly that.
We'll create a new project.
We'll understand how to explore more things using EXPRESS, and we'll be writing documentation for that
variety.
Now for this, we'll be again using the same package and everything, same that we have seen so far.
So make sure these tabs are opened up into some of your browser and I'll give you the presentation so
it helps you.
And again, we'll be using the most famous one, which is Swagger UI Express because it is most compatible
with the Express.
And apart from that, let me walk you through a couple of more basics.
So what all we'll be using for the documentation, we'll learn that how we can provide more options.
Maybe you are having multiple URL support and your request goes through multiple of the channels.
So we can work with that and I'll show you how you can inject variables in the entirety of the documentation.
And we'll be creating a new express project which will be having multiple routes and we'll write documentation
for that.
Most importantly, we will be using the open API version 3.0 or anything beyond three.
Now the difference is that what you have seen so far in the tutorial or maybe in the blog articles also
they might be a little bit outdated.
Doesn't mean that the 2.0 or two x version is not supported.
It is still yet fully supported and a whole lot of documentation still follow that kind of routine.
We won't be doing that.
We want to go as modern as possible, so we'll be referring the documentation of 3.0 as an open source
API recommendation and we'll be writing.
Same for that.
So make sure you don't just blindly copy paste from all the StackOverflow things that you see around
because 3.0 doesn't have too much of the things around on the web.
So make sure you keep an eye on that.
A lot of structure that you're going to see on the Web is actually 2.0.
So make sure you refer all the time the official guidelines and not the other blogs and stuff if they
are not updated.
Okay.
So this is all what we'll be doing and let's go ahead and create a new project.
So for this, I'll fire up my code.
My V is my terminal.
You can also do that.
So if I do a quick LZ, I can see I have a social app as of now.
Now let's go ahead and create a new directory.
So I'm going to go ahead and call this one as my my docs would be fine.
My docs ae yeah, that's fine.
Let's go ahead and seed into that.
My docs fine.
And here this time we won't be filling up all the details.
So I'm going to say just in NPM in a dash, why this allows to skip all the options and you can go ahead
and later on enter all these options manually yourself and let's fire up our code editor.
And by the way, we can install all the things from here as well.
You can do that from VZ code as well.
So this time I obviously know that I'll be using EXPRESS and I'll be using the Express, this swagger
UI Express.
So let's go ahead and use that.
I forgot this one.
So we're going to just say that I want the swagger UI express.
Sometimes it's confusing to remember that whether they have these dots or not.
So we're going to go ahead and use this.
And apart from this, we will be needing one more thing which is again recommended or mentioned in the
documentation itself.
So let's go a little bit on to the bottom section here.
There we go, yaml JS.
So this is one we'll be working on, so go ahead and copy paste that.
So these are the three major ones that we'll be using.
I already have mentioned to you that how Node one is being used as a dev dependency, but this time
I'm going to go ahead and install that as fully you now know and completely understand that what's the
difference and all of that.
So I won't be repeating that part again, so let's go ahead and install that.
And this shouldn't take too much of time.
Once this is all done, I would like to just open up my Visual Studio code up here.
That Visual Studio V is code.
So there we go.
Let's open up.
Yes, of course.
I do trust this and let's open this up.
Expand this a little bit.
There we go.
Now, let's see, in the package that JSON, we see all the node one and everything is up here.
I would like to add a start script and that start script will simply say that please run Node Mom and
I would love to run my index js with it, so save this.
This is all good.
We have already seen that in case of writing these documentation we need node mom dot json file.
This is already done with us.
And in this we are going to simply.
See, I need you to monitor these extensions, which is just a long string.
So Dot G's, dot JZ X and we will be going for dot yaml and this is all that we need as of now.
Once this is all done, let's go ahead and create a simple index file.
So let's go ahead and do that index.
JS And I'm pretty sure that a whole lot of you are now fully aware of how to do that.
So first thing is to require the express we have already done that.
So should be shouldn't be a much of a deal.
So we're going to go ahead and say express.
The next thing is to create a simple variable with the express.
So let's call this one Zap.
Feel free to call it anything else.
And we're going to go ahead and say Express is going to be responsible for this one.
After that, we simply go ahead and say, Hey, app, please listen and we need to define the port number
since we have already understood the importance of declaring the port into available and all of that,
I wouldn't be doing that again.
And this actually gives you a callback and you can go ahead and simply say console.log and we can just
simply say Server is running at Port 4000 and of course, triple dot.
These are important.
Not important, just for fun.
Okay, moving on then we have to simply create a route.
So we're going to simply say app, dot, get and you know, the basic idea of it, we need to have a
root something up here and then a callback.
This says request, this says response and we go ahead and do like this.
Then simply we can send a response and we can simply go ahead and say hello from AE.
So notice how quickly we were able to move forward because obviously we have done this in the past,
so this is all good.
Now moving further, we are going to go back up here and we are going to say, hey, we know that we
are bringing in swagger, so we need all of these lines.
So of course, if you remember them, that's great.
Otherwise you can go ahead and just grab them from the documentation itself.
So I'm going to go ahead and grab it from the documentation.
Some people just always like to write them.
I think if you know what you're doing, then writing or just bringing them up makes a kind of a sane
thing.
Now this actually in order to run need a swagger dot yaml.
Feel free to rename this file if you want.
I'm not interested in that, so I'm going to go ahead and say swagger if I can write that.
So I got a dot yaml and it looks great.
Okay, so this one also looks great.
Hopefully we haven't made any typos so we can go ahead and run the command and PM start and this should
be up and running.
So there we go.
And now let's go back onto our favorite browser, whatever that is, and we're going to go ahead and
move on to local host.
It says really tiny hello from AE.
Okay, so this is the basic setup that we have done.
In the next video, we'll start writing the documentation and don't you worry, I'll break them up into
shorter videos so that each topic actually addressed one single subject.
Let's go ahead and catch up in the next video.