In this exercise, you will learn how to create REST api end points and subdocuments:
- Building a RESTful API.
- Performing subdocument operations.
- Writing API endpoints.
- Fork this repo
- Clone this repo
Whenever you create a first significant change, you should make your first commit.
- Follow these guidelines to add, commit and push changes.
In the end of this document, you will find guidelines on how to submit the exercise.
In this project we will learn how to create a very simple Web API using Node.js
and Express
, and cover the basics of server-side routing
and using global middleware
.
Build a RESTful Web API to manage "Lessons" and "Squads". A Squad is a group chat channel that brings together an instructor and a group of students from the same cohort as they work on a Lesson.
An example would be a Squad created to go over the "Introduction to Node and Express" lesson for the Web 1 cohort.
A Lesson has:
- a unique
id
. - a
name
.
A Squad has:
- a unique
id
. - a
name
. - a
lessonId
that connects it to the corresponding Lesson. - a
cohort
.
The Web API must provide a set of endpoints
to fulfill the following needs:
- add a new Lesson.
- view a list of existing Lessons.
- view the details of a single Lesson
- update the information of an existing Lesson.
- remove a Lesson.
- add a new Squad.
- view a list of existing Squads.
- view the details of a single Squads
- update the information of an existing Squads.
- remove a Squad.
Your task in this iteration is to create a
EXPRESS
server.- An account in
Mongo Atlas
- connection between node and atlas using mongoose.
Here is a table with the endpoint
descriptions:
Action | URL | Method | Response |
---|---|---|---|
Add a Lesson | /api/lessons | POST | the new Lesson |
View list of Lessons | /api/lessons | GET | array of Lessons |
View Lesson details | /api/lessons/{id} | GET | a Lesson |
Update Lesson | /api/lessons/{id} | PUT | updated Lesson |
Remove a Lesson | /api/lessons/{id} | DELETE | deleted Lesson |
Add a Squad | /api/squad | POST | the new Squad |
View list of Squads | /api/squads | GET | array of Squads |
View Squad details | /api/squads/{id} | GET | a Squad |
Update Squad | /api/squads/{id} | PUT | updated Squad |
Remove a Squad | /api/squads/{id} | DELETE | deleted Squad |
Use populate
method from mongoose to display all the data.
If you didn't add, commit and push the changes you made, this is the last call. ๐
please share your github links with your Mentors. Your Mentor's will check up your work and provide feedback.
If you managed to do it, good job! ๐
We are proud of you!
Happy Coding ProGrad โค๏ธ!