This project manages favorite teacher-student relationships.
- Users can register themselves and then login upon which they'll recieve a JWT token which they can include in the headers of the rest of the API calls, key as "auth-token" and value as the token acquired
- Users can perform all the CRUD operations on teacher model
- Users can send a request to add a particular teacher to their favorite list and can remove it as well
- Users can also see the most favorite teacher and the count of users who added him/her to their favorite list
This project includes validation to validate credentials also performs checks to prevent accepting duplicate data
This project uses the following frameworks and languages
- NodeJs
- ExpressJs
- MongoDB
- Mongoose
Edit the dotenv file in the main repository to connect to the database on cloud.mongodb.com and update secret key token for JWT authorization
This project includes three collections in the database and they are as follows-
- Protocol:
http
- Port:
3000
- Base URL:
http://localhost:3000/
http://localhost:3000/api/user/register
This API can be used to add new student
Body
{
"name": "John Doe",
"email": "johndoe@gmail.com",
"password": "test123"
}
http://localhost:3000/api/user/login
This API can be used to login and returns JWT Token which can be used as Bearer Token for rest of the APIs.
Body
{
"email": "johndoe@gmail.com",
"password": "test123"
}
http://localhost:3000/api/teachers/
This API is used to get list of all the teachers
http://localhost:3000/api/teachers/
This API adds new teacher by adding JWT token in the header from successfully logging in as a user/student
Body
{
"name": "William Zane",
"email": "williamzane@gmail.com"
}
http://localhost:3000/api/teachers/635d2ed210d83ec27359cf42
This API can be used to get teacher info by passing it's id
http://localhost:3000/api/teachers/635d2ed210d83ec27359cf42
This API can be used to delete teacher info by passing it's id
http://localhost:3000/api/teachers/635d2ed210d83ec27359cf42
This API can be used to update teacher info by passing it's id
Body
{
"name": "William Zane",
"email": "williamzane36@gmail.com"
}
http://localhost:3000/api/teachers/favorite
This API is used to get the list of all the favorite teachers marked by the user/student
http://localhost:3000/api/teachers/favorite/635be09be3e6d5cffe0ae8fd
This API is used to add a teacher to favorite list by the user/student
http://localhost:3000/api/teachers/mostFavorite
This API is used to get the most favorite teacher among all the students/user and it also returns the count of students who marked them their favorite