1
00:00:00,330 --> 00:00:00,840
Beautiful.

2
00:00:01,230 --> 00:00:08,270
And once we're done with schema, set up the structure like we did for the previous model, where effectively

3
00:00:08,280 --> 00:00:11,100
we want to go with or a controller in the controllers.

4
00:00:11,280 --> 00:00:13,380
We want to set up all these functions.

5
00:00:13,710 --> 00:00:16,410
As far as the response, we already know the drill.

6
00:00:16,920 --> 00:00:23,280
After that, where you want to set up or else file in the root, get all the controllers only.

7
00:00:23,280 --> 00:00:23,880
Gotcha.

8
00:00:23,880 --> 00:00:31,500
Here is that I want get all orders accessible only to the admin.

9
00:00:32,159 --> 00:00:40,590
Now, rest of the order out still should be only available to the user if he or she has logged in.

10
00:00:41,130 --> 00:00:43,050
So we definitely want to set up that middleware.

11
00:00:43,470 --> 00:00:46,020
And this is the case where we'll use to all the routes.

12
00:00:46,800 --> 00:00:50,150
So if you want, you can set it up in an address, like I mentioned previously.

13
00:00:50,170 --> 00:00:54,960
But when it comes to get all or not only I want the user to be logged in.

14
00:00:55,500 --> 00:01:01,470
I also want only admins to access that run as far as that up typical rest.

15
00:01:01,620 --> 00:01:06,540
And then we have create and get all orders on root.

16
00:01:07,080 --> 00:01:15,280
And then when it comes to update and get single, or we'll use the colon in the root prime and then

17
00:01:15,600 --> 00:01:22,920
to get all current user orders, we're going to set up this shroud show all my orders.

18
00:01:23,280 --> 00:01:24,950
Just remember about the placement.

19
00:01:24,960 --> 00:01:30,410
That's something that we talked about and we want to import all routes as our objects.

20
00:01:31,230 --> 00:01:34,450
And this is going to be my route euro.

21
00:01:34,920 --> 00:01:39,210
So let's get cracking and we're looking for controllers.

22
00:01:39,780 --> 00:01:40,980
We want to go with order.

23
00:01:42,310 --> 00:01:49,700
Controller controller, yes, and in order to speed this up, I will right away grab everything from

24
00:01:49,700 --> 00:01:50,240
the read me.

25
00:01:51,900 --> 00:02:01,320
So or a controller will go or hide away with module module exports, and we'll copy and paste some exporting

26
00:02:01,320 --> 00:02:01,830
all of them.

27
00:02:02,220 --> 00:02:08,100
And now let's set them up one by one and I'll start with create or because that will be the toughest

28
00:02:08,100 --> 00:02:08,340
one.

29
00:02:08,490 --> 00:02:14,790
We have a bunch of moving pieces, and after that I can guarantee there's going to be smooth sailing

30
00:02:14,790 --> 00:02:15,310
from there.

31
00:02:15,330 --> 00:02:17,070
So let's go here with create.

32
00:02:18,040 --> 00:02:18,370
Order.

33
00:02:18,820 --> 00:02:21,790
And since it's the toughest one will work on it first as well.

34
00:02:22,270 --> 00:02:30,490
So it sank Rick and Rose Man as far as response, like I said, there was not sand and I just say,

35
00:02:30,490 --> 00:02:33,520
create order and now you want to set up rest of them.

36
00:02:34,400 --> 00:02:35,720
So let me copy and paste.

37
00:02:36,560 --> 00:02:40,930
I know how many I have there for, and I need five seven here.

38
00:02:41,660 --> 00:02:44,300
Get all orders.

39
00:02:44,900 --> 00:02:45,800
Same deal here.

40
00:02:47,090 --> 00:02:54,770
Get orders, Van get single order and get single single order.

41
00:02:56,420 --> 00:02:57,710
Yet in the lower.

42
00:02:59,620 --> 00:03:05,080
Then we want to show all the orders that are associated with current user.

43
00:03:06,140 --> 00:03:08,720
And in this case, I'm going to call this get.

44
00:03:09,880 --> 00:03:12,310
Current year, their orders.

45
00:03:13,350 --> 00:03:17,570
I read the same thing here and got current user orders.

46
00:03:18,760 --> 00:03:22,510
And let's also update the order, that order.

47
00:03:23,600 --> 00:03:25,280
And I did order here as well.

48
00:03:26,510 --> 00:03:28,000
Then we want to import.

49
00:03:29,030 --> 00:03:35,930
Everything into a route's file, which we haven't set up yet, so it's called this order.

50
00:03:37,190 --> 00:03:38,890
ROUTS, Jay, yes.

51
00:03:39,690 --> 00:03:42,830
And just so I can speed this up a little bit.

52
00:03:43,760 --> 00:03:45,650
I'll take a look at the reviews roots.

53
00:03:46,790 --> 00:03:51,920
And I'll grab everything up to a line 11.

54
00:03:53,330 --> 00:03:58,130
So take all of this, we are navigating back to the order.

55
00:03:58,160 --> 00:03:58,630
Ouch.

56
00:03:59,420 --> 00:04:00,440
Copy and paste.

57
00:04:00,890 --> 00:04:04,580
So we set up the router, that's step number one.

58
00:04:05,370 --> 00:04:06,620
Then what do we want to do?

59
00:04:07,540 --> 00:04:12,460
We want to get both, in my case, I'll set them up right here, so I want to get both.

60
00:04:12,820 --> 00:04:18,579
I want to get authenticate user as well as, like I just mentioned, authorized.

61
00:04:19,600 --> 00:04:20,279
Permissions.

62
00:04:20,709 --> 00:04:22,420
That's the second middle, what I want.

63
00:04:22,840 --> 00:04:25,380
This is coming from authentication run.

64
00:04:25,990 --> 00:04:29,470
We'll look for the audio controller, whatever we're exploring.

65
00:04:30,580 --> 00:04:36,850
Or here and then it's not going to be a review to be a or a controller.

66
00:04:37,450 --> 00:04:43,000
Now as far as out, it's going to look something like this where we go with an router throughout.

67
00:04:43,000 --> 00:04:48,250
And remember the route route is going to be this one API ever and one orders.

68
00:04:48,730 --> 00:04:50,710
So part depakote arrest set up.

69
00:04:51,340 --> 00:04:53,500
Well, place here a post one.

70
00:04:53,620 --> 00:04:55,390
But remember?

71
00:04:56,510 --> 00:05:02,780
Unless you set up the authenticate user in the address, which is also an option, once you complete

72
00:05:02,780 --> 00:05:05,330
everything, you will need to add it here.

73
00:05:05,660 --> 00:05:12,380
So Marcus, I'm going to go with authenticate user karma and then create or I know I'm repeating this,

74
00:05:12,380 --> 00:05:18,080
but I like this set because that way I can clearly see what malware are using.

75
00:05:18,170 --> 00:05:19,430
Otherwise you're looking at it.

76
00:05:19,430 --> 00:05:22,220
You're like, OK, I have authorized permissions.

77
00:05:22,250 --> 00:05:28,220
Technically, I remember that I can only use it if I have authenticate user, but it just helps me if

78
00:05:28,220 --> 00:05:32,210
I go to the roots and I can clearly see, OK, this is the middleware I'm using.

79
00:05:32,480 --> 00:05:33,970
Is this something you need to follow?

80
00:05:34,250 --> 00:05:34,700
No.

81
00:05:34,910 --> 00:05:37,900
If you like the other set up, feel free to do that instead.

82
00:05:38,600 --> 00:05:43,490
This is just my preference, and therefore I'm going to set it up in this fashion.

83
00:05:43,850 --> 00:05:45,580
Then we want to go with get out.

84
00:05:46,070 --> 00:05:50,450
So this is going to be get all orders, but we need to do two things.

85
00:05:50,480 --> 00:05:52,880
First, we want to authenticate the user.

86
00:05:53,270 --> 00:05:53,720
Correct.

87
00:05:54,020 --> 00:05:59,050
And second, I only want admin to access these results.

88
00:05:59,060 --> 00:06:00,410
So we go here with.

89
00:06:01,350 --> 00:06:03,750
Authorised and permissions, correct?

90
00:06:04,050 --> 00:06:05,310
And what do we want to pass in?

91
00:06:05,760 --> 00:06:13,530
I mean, of course, let's say that when we want to go with our ID where we're looking for specific

92
00:06:13,530 --> 00:06:20,470
work and we want to update so Browder author out Ron Colon I.D..

93
00:06:21,630 --> 00:06:27,300
And then get get single order, get single order.

94
00:06:27,960 --> 00:06:29,910
We also want updates and for both of them.

95
00:06:30,540 --> 00:06:35,970
Why do we want to add here, authenticate user karma, authenticate user here.

96
00:06:36,570 --> 00:06:38,580
And then let's go with batch.

97
00:06:39,980 --> 00:06:45,040
Ranch animals set up here got authenticate user and then karma.

98
00:06:45,400 --> 00:06:49,000
And we want to go with update, update order.

99
00:06:49,510 --> 00:06:56,920
And then lastly, I want to show all the orders that are associated with the current user.

100
00:06:57,280 --> 00:07:05,800
But since my URL is for show, all my users like a showcase already previously, we need to remember

101
00:07:05,800 --> 00:07:13,720
that this will be treated as that I.D. that show all my work and therefore will place it above.

102
00:07:14,360 --> 00:07:16,360
Go here with not route.

103
00:07:17,830 --> 00:07:22,570
We're out, and as far as the road is going to be, show all my users.

104
00:07:23,060 --> 00:07:23,830
Or sorry.

105
00:07:24,130 --> 00:07:25,810
Show all my orders.

106
00:07:27,110 --> 00:07:27,550
Order.

107
00:07:28,520 --> 00:07:29,320
Come on.

108
00:07:29,900 --> 00:07:32,480
Same deal you want to authenticate, of course.

109
00:07:33,200 --> 00:07:40,640
So it's going to be a get out front, authenticate user, authenticate user karma and get.

110
00:07:41,300 --> 00:07:46,610
And we're looking for that current, I believe, get current user orders.

111
00:07:47,150 --> 00:07:53,570
We say this and then the last step is in the app jazz, where we navigate back.

112
00:07:54,450 --> 00:07:56,250
I'm looking for the aurora.

113
00:07:58,040 --> 00:08:02,150
Order router or else or else.

114
00:08:02,690 --> 00:08:04,790
And then lastly, what are we going to do?

115
00:08:05,240 --> 00:08:06,920
We want to set up over here?

116
00:08:07,910 --> 00:08:14,980
And no one does that in a postman corrects their orders online or router.

117
00:08:15,530 --> 00:08:20,630
Let's say this and next video test everything in the postman.

