All right, and once the user models in place now, let's hop over to comptrollers more specifically
registered controller and let's do initial setup.
And let me tell you right from the get go that yes, a lot of things will change, but I want to make
those changes together and step by step.
So that way we all are on the same page.
And first of all, I want you to import user model one temporarily set up, try and catch in the try
block.
Try to create the user using user.
Not create passing the right down body.
That's where the values are going to be located.
And then if it's success, then send back to one with JSON response and user in it, then this is going
to be temporary.
And no, we're not hashing passwords at the moment and all that.
And then if there is an error, let's just go with something generic 500 and then the message there
was on error.
So let's hop over there.
We're looking for the off controller, and I probably should add that here so I can go here and I'll
say off.
Controller, so let's say I want online back in the controller, we have the register, and the first
thing we want is to import user.
So I'm looking for my user, it's going to be coming from online.
We're looking in the models, correct?
And then more specifically, looking for user one.
So once I have this one in place since will try to implement some asynchronous functions in the register
we want to do is set up right away, try and catch and in the try, block and try to create the user.
So we're going to go with the user and a white and user dot create and nothing here.
Let's passing the correct not body because again, that's where all the values are going to be located.
And remember that in the server address, we already have expressed Jason very, very important detail.
And if we're successful again for the time being, just for time being, we're going to go with status.
And then that one will be equal to two one.
And then I want to send back my years or so, Jason and the user.
Now, if there is an error.
Let's quickly copy and paste and we're going to go here with five hundred and nine instead of the user.
I'll just go with generic message and we're going to go.
There was an error and once we have a list in place now, I want to hop over to my postman and create
that request.
So let's go here.
We're looking for off.
We want to go with Registre user and I said, You're not here for the logging.
Also right user.
So and then in the register, we want to go with body.
Now that will be what I will be wrong.
And we're going to go with Jason.
And effectively, what are we looking for here?
Well, what are the properties that are required in the user?
It is name.
It is the email as well as the password.
My name and location have different powers, so those arms will just send back.
So let's go here and I'm going to go with the name.
I'm going to set it equal to John Van as far as the password.
I'm going to go with secret my famous secret here.
So secret in mind when it comes to email.
Let's just set it up as I don't know whatever you want.
In my case, I'm going to go with John at gmail.com.
So John at.
The Gmail dot com, let's send this and let's see what is going to be your response.
At the moment, I don't see anything.
So let's see.
Let's see.
Let's say we crashed, something didn't happen, cannot find the module users and I think I know what's
happening here.
Yep.
Of course I forgot to address.
So this is one of those things.
Or when you're working with your six modules, make sure that you add the extension.
Otherwise, you can clearly see what is going to be the error.
So let's try one more time.
I'm going to go with my request.
I send it.
And yep, I have my user.
Everything is awesome.
And like, if I take a look at the MongoDB, I should also see my database basically drop if I one and
then I have users collection with my juniors.
Now, if I'm going to try to submit this without providing one of the values that is required, we should
get back the 500 error.
Correct.
So let's say, if I were to remove the email here and try to submit, we should get back five hundred.
And if that is the case, which it is, honestly, I have a message.
There was an error.
Then we're in good shape.
So our initial functionality works if we provide all the values that we nicely create the user.
However, if one of the values is missing and I'm not going to test with each and every value, that's
just going to be too time consuming.
You saw how it worked with, I believe it was email.
Then we get back of this error and once we have the initial functionality in place now, we can move
on to the next step.