It's time for the very first assignment in this course.
In this module, we have been exploring the details of node modules.
We also looked at their node support for HTTP,
the express framework and also express router,
and we saw how we can use express router to implement the support for the recipient.
In this assignment, you will continue with
this theme The first task of your assignment is to complete the dishRouter.
In the dishRouter, we had implemented support for the slash dishes endpoint.
We're going to now extend that to support the access to
a specific dish by supplying the ID of the dish.
So, for localhost:3000/dishes/:dishId.
So when the dishId specified,
you should be able to support the get, put,
post and delete operations for a specific chosen dish.
This code should be implemented inside that dishrouter.js file.
Your second task in this assignment is to add
a new express router called promoteRouter and the file promoteRouter.js.
This is where you will support the two HTTP endpoints for
localhost: 3000/promotions and localhost:3000/promotions/:promoId.
There get, put, post,
and delete operations should be supported on all these two endpoints.
The final task in this assignment is to implement yet another express
router now called leaderRouter.js which supports access to the rest API endpoints,
localhost: 3000/leaders and localhost:3000/leaders/:leaderId.
So once you complete this,
you will see that your express router now supports
the entire set of rest API endpoints for dishes,
promotions, and the leaders.
And this will be very useful for us to hook this
up with the client side application that we have
been implemented in the previous four courses of this specialization.
We'll come to that part towards the end of this course,
but now we'll learn how to set up the rest API support within our express router.
Now let's look at how this works by going to postman and then sending some requests to
these endpoints and see the reply from
the server site when a request is sent to these endpoints.
So, going to post line, now,
I should be able to send a get request to
localhost:3000/dishes/23 and it should return the details as shown here.
Then we can send the request to post an item to
the endpoint and it says post-operation not supported.
Then we can do a put on the endpoint and then it will
update the chosen dish and then we do a delete and touch it, delete the dish.
Now same thing, we will do a get on
promotions and that should return saying will send all promotions to you then
we can do a put
on promotions and should say put operation not supported.
We can do a post
on promotions and that should send the details as shown here.
So the body will include the name,
test and description just like we did before and the delete also.
Similarly, we can do a put on
promotions/23 and that should again say updating the promotion: 23,
will update the promotion test with details test description, like that.
So, we can also do the same thing with
leaders and they should say updating the leader: 23 will,
update the leader: test with details: test description.
If you do a post on that,
it will not allow the operation and should print out the message as shown here.
You can do a get on that and that should say it
will send the details of number 23 to you.
If you do a get on the leaders,
it'll say we'll send all the leaders to you.
So you see that all the four operations and
all the six different endpoints will be supported after you complete this assignment.
Have fun completing the very first assignment of this course.