All right.
And up next, let's set up our controllers.
So we're looking for register and login controller.
And also we want to set up the router.
And this is the case where I encourage you to stop the video and try to set it up yourself.
So again, you're looking for two controllers.
You want to set up the router.
In my case, I'm going to call this auth router and the full path is going to be API version one and
auth.
And then of course the user either goes to register or log in.
So if you're interested, stop the video and resume once you're ready to compare the results.
Okay, so let's get started.
In my case, I'm going to go to Controllers folder.
I'm looking for auth controller.
James.
And we want to set up those two functions.
So export const, register, it's going to be async, so we might as well set it up.
Right now it's going to have req and res.
That also stays the same.
And for now let's just go with res.send and.
Let's go with the register here.
Okay.
Beautiful.
Then we want to copy and paste this.
And of course, change it around.
So.
Register is going to be a login.
Then let's create a new router.
So in this case, I'm going to call this auth router.
JS And let's start by importing the router from Express.
Now, of course, if you want, you can copy and paste and just change the values.
But in my case, I'll start everything from scratch.
We're looking for login and register and both of them are coming from the controllers.
So let's go here to auth controller, let's add JS, Otherwise we'll have some bugs.
We want to create the router.
And you know what?
Actually let me move this down.
So this is going to be an import for router and then I'll have my own imports.
So router is equal to router.
Let's invoke this one and let's set up the two routes.
Now this is the case where I will go with router dot and then post.
Basically, I'm not going to go with the router dot route since I'm not going to change anything.
Remember we had two approaches, so now I'm going to use the first one.
So router post.
So this is going to be a post route where it's going to go to a register here and then which controller
we want to use of course the register one, and then we want to change this and around.
So this will be a login one and make sure to export our router.
And we're looking for default one, of course.
So we're going to go with export default and router.
Then at the very end, we want to go to a server.
Then I want to look for my router import.
So we're here.
Basically, we just want to change some things around.
So this will be auth router.
And it's coming from the auth.
Router file.
Then let's keep on moving.
Notice here API version jobs.
So the base URL is going to be a little bit different.
It's going to be auth.
And we're looking for auth router.
So now let's navigate to Thunder client.
We're looking for collections recording one.
At least in my case, I want to create a new folder.
And in this case, I'm going to call this author out.
And here we'll create one for register and one for login one.
So let's create a new request.
So call this a register user.
Not going to be a get request.
It's going to be a post request.
For now, let's just use the URL.
Remember that's our global one, then auth and then a register.
Let's send.
And if everything is correct, we should see.
Register in response.
And pretty much we want to duplicate this one.
And we just want to change some values here.
First of all, I want to rename it.
We're going to go with.
Register user.
Or I'm sorry, we want to go with login user.
My bad.
And then in here the method is still post, so that doesn't change.
But of course the URL is a little bit different.
So now we want to log in and if everything is correct, we should see a login in response.
And with this in place we can move on to the next step.