Team members:
- BUOMPANE LORENZO
- DEMATTIA GIACOMO
- CHESSA MARCO
A general description of the BigLab 2 is avaible in the course-materials
repository, under labs. In the same repository, you can find the instructions for GitHub Classroom, covering BigLabs and exam sessions.
Once you cloned this repository, please write the group name and names of the members of the group in the above section.
In the client
directory, do NOT create a new folder for the project, i.e., client
should directly contain the public
and src
folders and the package.json
files coming from BigLab1.
When committing on this repository, please, do NOT commit the node_modules
directory, so that it is not pushed to GitHub.
This should be already automatically excluded from the .gitignore
file, but double-check.
When another member of the team pulls the updated project from the repository, remember to run npm install
in the project directory to recreate all the Node.js dependencies locally, in the node_modules
folder.
Remember that npm install
should be executed inside the client
and server
folders (not in the BigLab2
root directory).
Finally, remember to add the final
tag for the final submission, otherwise it will not be graded.
Here you can find a list of the users already registered inside the provided database. This information will be used during the fourth week, when you will have to deal with authentication. If you decide to add additional users, please remember to add them to this table (with plain-text password)!
password | name | |
---|---|---|
[email protected] | password | John |
[email protected] | password | Mario |
[email protected] | password | User test |
- URL:
/api/v1/films
- HTTP Method: GET
- Description: Return the list of the films of the logged user
- Request body: None
- Response:
200 OK
(success) or500 Internal Server Error
(generic error) or400 Bad Request
(not authenticated) - Response body:
[
{
"id": 4,
"title": "Cars3",
"favorite": 0,
"watchdate": "2022-05-27",
"rating": 4,
"user": 2
},
{
"id": 5,
"title": "Shrek",
"favorite": 0,
"watchdate": "2022-03-21",
"rating": 3,
"user": 2
}
]
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/:id
- HTTP Method: GET
- Description: Return the selected film of the logged user
- Request body: None
- Response:
200 OK
(success) or500 Internal Server Error
(generic error) or404 Not found
(film doesn't exist) or400 Bad Request
(not authenticated) - Response body:
{
"id": 4,
"title": "Matrix",
"favorite": 0,
"watchdate": null,
"rating": null,
"user": 2
}
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/filter/:filter
- HTTP Method: GET
- Description: Return the list of films filtered according to the filter in the parameters
- Request body: None
- Response:
200 OK
(success) or500 Internal Server Error
(generic error) or400 Bad Request
(not authenticated) - Response body:
For unseen filter
[
{
"id": 4,
"title": "Matrix",
"favorite": 0,
"watchdate": null,
"rating": null,
"user": 2
}
]
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/
- HTTP Method: POST
- Description: Create a new film
- Request body:
{
"title": "Cars",
"favorite": 1,
"watchdate": "27/05/2022",
"rating": 5,
"user": 1
}
- Response:
201 OK
(success) or503 Internal Server Error
(generic error) or400 Bad Request
(not authenticated) - Response body: None
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/:id
- HTTP Method: PUT
- Description: Modify the selected film of the logged user
- Request body:
{
"id": 4,
"title": "Matrix",
"favorite": 0,
"watchdate": null,
"rating": null
}
- Response:
200 OK
(success) or500 Internal Server Error
(generic error) or404 Not found
(film doesn't exist) or400 Bad Request
(not authenticated) - Response body: None
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/:id/favorite
- HTTP Method: PUT
- Description: Modify favorite in line of the selected film of the logged user
- Request body: None
- Response:
200 OK
(success) or500 Internal Server Error
(generic error) or404 Not found
(film doesn't exist) or400 Bad Request
(not authenticated) - Response body: None
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/films/:id
- HTTP Method: DELETE
- Description: Delete the selected film of the logged user
- Request body: None
- Response:
204 OK
(success) or500 Internal Server Error
(generic error) or404 Not found
(film doesn't exist) or400 Bad Request
(not authenticated) - Response body: None
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}
- URL:
/api/v1/login
- HTTP Method: POST
- Description: Authenticate the user
- Request body:
{
"username" : "[email protected]",
"password" : "password"
}
- Response:
200 OK
(success) - Response body:
{
"id": 2,
"name": "Mario",
"email": "[email protected]"
}
- URL:
/api/v1/logout
- HTTP Method: POST
- Description: Logout of logged user
- Request body: None
- Response:
200 OK
(success) or400 Bad Request
(not authenticated) - Response body: None
- Error response:
For 400 Bad Request status:
{
"message": "Not authenticated"
}