1
00:00:00,210 --> 00:00:06,140
All right, and once the user models in place now, let's hop over to comptrollers more specifically

2
00:00:06,210 --> 00:00:08,910
registered controller and let's do initial setup.

3
00:00:09,150 --> 00:00:16,079
And let me tell you right from the get go that yes, a lot of things will change, but I want to make

4
00:00:16,079 --> 00:00:18,540
those changes together and step by step.

5
00:00:18,550 --> 00:00:21,450
So that way we all are on the same page.

6
00:00:21,870 --> 00:00:29,880
And first of all, I want you to import user model one temporarily set up, try and catch in the try

7
00:00:29,880 --> 00:00:30,240
block.

8
00:00:30,630 --> 00:00:33,360
Try to create the user using user.

9
00:00:33,370 --> 00:00:35,520
Not create passing the right down body.

10
00:00:35,820 --> 00:00:38,250
That's where the values are going to be located.

11
00:00:38,520 --> 00:00:46,320
And then if it's success, then send back to one with JSON response and user in it, then this is going

12
00:00:46,320 --> 00:00:47,060
to be temporary.

13
00:00:47,070 --> 00:00:50,280
And no, we're not hashing passwords at the moment and all that.

14
00:00:50,520 --> 00:00:55,920
And then if there is an error, let's just go with something generic 500 and then the message there

15
00:00:55,920 --> 00:00:57,330
was on error.

16
00:00:57,720 --> 00:01:00,180
So let's hop over there.

17
00:01:01,020 --> 00:01:07,980
We're looking for the off controller, and I probably should add that here so I can go here and I'll

18
00:01:07,980 --> 00:01:08,780
say off.

19
00:01:10,000 --> 00:01:16,900
Controller, so let's say I want online back in the controller, we have the register, and the first

20
00:01:16,900 --> 00:01:19,420
thing we want is to import user.

21
00:01:19,580 --> 00:01:23,520
So I'm looking for my user, it's going to be coming from online.

22
00:01:23,530 --> 00:01:25,180
We're looking in the models, correct?

23
00:01:25,660 --> 00:01:28,690
And then more specifically, looking for user one.

24
00:01:29,230 --> 00:01:35,320
So once I have this one in place since will try to implement some asynchronous functions in the register

25
00:01:35,850 --> 00:01:43,480
we want to do is set up right away, try and catch and in the try, block and try to create the user.

26
00:01:43,600 --> 00:01:49,990
So we're going to go with the user and a white and user dot create and nothing here.

27
00:01:49,990 --> 00:01:55,170
Let's passing the correct not body because again, that's where all the values are going to be located.

28
00:01:55,180 --> 00:02:02,530
And remember that in the server address, we already have expressed Jason very, very important detail.

29
00:02:02,900 --> 00:02:10,180
And if we're successful again for the time being, just for time being, we're going to go with status.

30
00:02:10,960 --> 00:02:13,040
And then that one will be equal to two one.

31
00:02:13,510 --> 00:02:17,980
And then I want to send back my years or so, Jason and the user.

32
00:02:18,220 --> 00:02:19,450
Now, if there is an error.

33
00:02:19,810 --> 00:02:26,320
Let's quickly copy and paste and we're going to go here with five hundred and nine instead of the user.

34
00:02:26,750 --> 00:02:29,680
I'll just go with generic message and we're going to go.

35
00:02:29,720 --> 00:02:38,800
There was an error and once we have a list in place now, I want to hop over to my postman and create

36
00:02:38,800 --> 00:02:39,490
that request.

37
00:02:40,330 --> 00:02:41,320
So let's go here.

38
00:02:41,650 --> 00:02:42,670
We're looking for off.

39
00:02:42,820 --> 00:02:47,560
We want to go with Registre user and I said, You're not here for the logging.

40
00:02:48,190 --> 00:02:49,880
Also right user.

41
00:02:50,530 --> 00:02:54,400
So and then in the register, we want to go with body.

42
00:02:54,880 --> 00:02:57,860
Now that will be what I will be wrong.

43
00:02:58,120 --> 00:02:59,680
And we're going to go with Jason.

44
00:03:00,190 --> 00:03:02,200
And effectively, what are we looking for here?

45
00:03:02,230 --> 00:03:06,310
Well, what are the properties that are required in the user?

46
00:03:06,970 --> 00:03:07,570
It is name.

47
00:03:08,050 --> 00:03:10,840
It is the email as well as the password.

48
00:03:11,320 --> 00:03:16,570
My name and location have different powers, so those arms will just send back.

49
00:03:17,020 --> 00:03:20,050
So let's go here and I'm going to go with the name.

50
00:03:20,650 --> 00:03:24,880
I'm going to set it equal to John Van as far as the password.

51
00:03:25,510 --> 00:03:28,840
I'm going to go with secret my famous secret here.

52
00:03:29,200 --> 00:03:32,300
So secret in mind when it comes to email.

53
00:03:32,950 --> 00:03:36,040
Let's just set it up as I don't know whatever you want.

54
00:03:36,040 --> 00:03:40,540
In my case, I'm going to go with John at gmail.com.

55
00:03:40,570 --> 00:03:42,220
So John at.

56
00:03:43,130 --> 00:03:48,770
The Gmail dot com, let's send this and let's see what is going to be your response.

57
00:03:49,430 --> 00:03:52,520
At the moment, I don't see anything.

58
00:03:52,940 --> 00:03:53,480
So let's see.

59
00:03:53,480 --> 00:03:53,780
Let's see.

60
00:03:53,780 --> 00:04:01,400
Let's say we crashed, something didn't happen, cannot find the module users and I think I know what's

61
00:04:01,400 --> 00:04:02,000
happening here.

62
00:04:02,450 --> 00:04:02,810
Yep.

63
00:04:03,380 --> 00:04:04,820
Of course I forgot to address.

64
00:04:05,170 --> 00:04:06,500
So this is one of those things.

65
00:04:06,530 --> 00:04:13,670
Or when you're working with your six modules, make sure that you add the extension.

66
00:04:13,970 --> 00:04:17,300
Otherwise, you can clearly see what is going to be the error.

67
00:04:17,310 --> 00:04:18,440
So let's try one more time.

68
00:04:18,940 --> 00:04:20,959
I'm going to go with my request.

69
00:04:21,200 --> 00:04:21,860
I send it.

70
00:04:22,280 --> 00:04:24,740
And yep, I have my user.

71
00:04:25,120 --> 00:04:26,270
Everything is awesome.

72
00:04:26,540 --> 00:04:34,250
And like, if I take a look at the MongoDB, I should also see my database basically drop if I one and

73
00:04:34,250 --> 00:04:38,470
then I have users collection with my juniors.

74
00:04:39,110 --> 00:04:47,510
Now, if I'm going to try to submit this without providing one of the values that is required, we should

75
00:04:47,510 --> 00:04:49,430
get back the 500 error.

76
00:04:49,760 --> 00:04:50,180
Correct.

77
00:04:50,630 --> 00:05:00,350
So let's say, if I were to remove the email here and try to submit, we should get back five hundred.

78
00:05:00,710 --> 00:05:03,920
And if that is the case, which it is, honestly, I have a message.

79
00:05:03,920 --> 00:05:04,570
There was an error.

80
00:05:04,950 --> 00:05:06,200
Then we're in good shape.

81
00:05:06,210 --> 00:05:14,540
So our initial functionality works if we provide all the values that we nicely create the user.

82
00:05:14,900 --> 00:05:19,540
However, if one of the values is missing and I'm not going to test with each and every value, that's

83
00:05:19,550 --> 00:05:20,990
just going to be too time consuming.

84
00:05:21,320 --> 00:05:24,140
You saw how it worked with, I believe it was email.

85
00:05:24,530 --> 00:05:30,710
Then we get back of this error and once we have the initial functionality in place now, we can move

86
00:05:30,710 --> 00:05:31,940
on to the next step.

