1
00:00:03,920 --> 00:00:08,805
It's time for the very first assignment in this course.

2
00:00:08,805 --> 00:00:15,870
In this module, we have been exploring the details of node modules.

3
00:00:15,870 --> 00:00:19,545
We also looked at their node support for HTTP,

4
00:00:19,545 --> 00:00:23,809
the express framework and also express router,

5
00:00:23,809 --> 00:00:29,900
and we saw how we can use express router to implement the support for the recipient.

6
00:00:29,900 --> 00:00:34,995
In this assignment, you will continue with

7
00:00:34,995 --> 00:00:43,315
this theme The first task of your assignment is to complete the dishRouter.

8
00:00:43,315 --> 00:00:49,520
In the dishRouter, we had implemented support for the slash dishes endpoint.

9
00:00:49,520 --> 00:00:53,670
We're going to now extend that to support the access to

10
00:00:53,670 --> 00:00:58,260
a specific dish by supplying the ID of the dish.

11
00:00:58,260 --> 00:01:03,650
So, for localhost:3000/dishes/:dishId.

12
00:01:03,650 --> 00:01:05,730
So when the dishId specified,

13
00:01:05,730 --> 00:01:07,490
you should be able to support the get, put,

14
00:01:07,490 --> 00:01:11,715
post and delete operations for a specific chosen dish.

15
00:01:11,715 --> 00:01:17,050
This code should be implemented inside that dishrouter.js file.

16
00:01:17,050 --> 00:01:20,550
Your second task in this assignment is to add

17
00:01:20,550 --> 00:01:27,385
a new express router called promoteRouter and the file promoteRouter.js.

18
00:01:27,385 --> 00:01:32,055
This is where you will support the two HTTP endpoints for

19
00:01:32,055 --> 00:01:40,925
localhost: 3000/promotions and localhost:3000/promotions/:promoId.

20
00:01:40,925 --> 00:01:43,515
There get, put, post,

21
00:01:43,515 --> 00:01:49,553
and delete operations should be supported on all these two endpoints.

22
00:01:49,553 --> 00:01:56,265
The final task in this assignment is to implement yet another express

23
00:01:56,265 --> 00:02:03,176
router now called leaderRouter.js which supports access to the rest API endpoints,

24
00:02:03,176 --> 00:02:12,690
localhost: 3000/leaders and localhost:3000/leaders/:leaderId.

25
00:02:12,690 --> 00:02:14,490
So once you complete this,

26
00:02:14,490 --> 00:02:18,360
you will see that your express router now supports

27
00:02:18,360 --> 00:02:22,635
the entire set of rest API endpoints for dishes,

28
00:02:22,635 --> 00:02:24,955
promotions, and the leaders.

29
00:02:24,955 --> 00:02:27,330
And this will be very useful for us to hook this

30
00:02:27,330 --> 00:02:29,850
up with the client side application that we have

31
00:02:29,850 --> 00:02:35,035
been implemented in the previous four courses of this specialization.

32
00:02:35,035 --> 00:02:39,475
We'll come to that part towards the end of this course,

33
00:02:39,475 --> 00:02:47,895
but now we'll learn how to set up the rest API support within our express router.

34
00:02:47,895 --> 00:02:54,480
Now let's look at how this works by going to postman and then sending some requests to

35
00:02:54,480 --> 00:02:57,900
these endpoints and see the reply from

36
00:02:57,900 --> 00:03:03,130
the server site when a request is sent to these endpoints.

37
00:03:03,130 --> 00:03:05,980
So, going to post line, now,

38
00:03:05,980 --> 00:03:09,300
I should be able to send a get request to

39
00:03:09,300 --> 00:03:18,735
localhost:3000/dishes/23 and it should return the details as shown here.

40
00:03:18,735 --> 00:03:23,340
Then we can send the request to post an item to

41
00:03:23,340 --> 00:03:28,423
the endpoint and it says post-operation not supported.

42
00:03:28,423 --> 00:03:33,930
Then we can do a put on the endpoint and then it will

43
00:03:33,930 --> 00:03:40,245
update the chosen dish and then we do a delete and touch it, delete the dish.

44
00:03:40,245 --> 00:03:47,870
Now same thing, we will do a get on

45
00:03:49,660 --> 00:04:00,285
promotions and that should return saying will send all promotions to you then

46
00:04:00,285 --> 00:04:08,485
we can do a put

47
00:04:08,485 --> 00:04:14,925
on promotions and should say put operation not supported.

48
00:04:14,925 --> 00:04:17,590
We can do a post

49
00:04:17,590 --> 00:04:27,396
on promotions and that should send the details as shown here.

50
00:04:27,396 --> 00:04:29,290
So the body will include the name,

51
00:04:29,290 --> 00:04:33,770
test and description just like we did before and the delete also.

52
00:04:33,770 --> 00:04:39,670
Similarly, we can do a put on

53
00:04:39,670 --> 00:04:47,735
promotions/23 and that should again say updating the promotion: 23,

54
00:04:47,735 --> 00:04:52,845
will update the promotion test with details test description, like that.

55
00:04:52,845 --> 00:04:56,440
So, we can also do the same thing with

56
00:04:56,440 --> 00:05:02,940
leaders and they should say updating the leader: 23 will,

57
00:05:02,940 --> 00:05:06,105
update the leader: test with details: test description.

58
00:05:06,105 --> 00:05:08,920
If you do a post on that,

59
00:05:08,920 --> 00:05:15,620
it will not allow the operation and should print out the message as shown here.

60
00:05:15,620 --> 00:05:19,980
You can do a get on that and that should say it

61
00:05:19,980 --> 00:05:25,255
will send the details of number 23 to you.

62
00:05:25,255 --> 00:05:26,925
If you do a get on the leaders,

63
00:05:26,925 --> 00:05:29,150
it'll say we'll send all the leaders to you.

64
00:05:29,150 --> 00:05:32,410
So you see that all the four operations and

65
00:05:32,410 --> 00:05:41,454
all the six different endpoints will be supported after you complete this assignment.

66
00:05:41,454 --> 00:05:47,390
Have fun completing the very first assignment of this course.