This project has been developed by team described below for the course of "Applicazioni Web I", attended during the academic year 2021/22 at Politecnico di Torino, Master's Degree in Computer Engineering.
- ANDRIANO DAVIDE
- BELARDO ANNA LISA
- DELUCA ANDREA
- TAMBURO LUCA
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 this and the next BigLab.
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 please 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 | Testuser |
Provide a short description of the API you designed, with the required parameters. Please follow the proposed structure.
- [HTTP Method] [URL, with any parameter]
- [One-line about what this API is doing]
- [A (small) sample request, with body (if any)]
- [A (small) sample response, with body (if any)]
- [Error responses, if any]
Hereafter, we report the designed HTTP APIs, also implemented in the project.
Performs user authentication and create a new session for the user.
Content-Type: application/json
A JSON object containing username and password.
{
"username": "[email protected]",
"password": "password"
}
HTTP status code 200 OK
{
"id": "3",
"email": "[email protected]",
"name": "Testuser",
}
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 401 Unauthorized
(credentials error)
Performs user logout and delete the current user session.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)
Gets information about the user, if he is logged in.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
{
"id": "3",
"email": "[email protected]",
"name": "Testuser",
}
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(user not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets all films associated with the logged in user.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
[
{
"id": "1",
"title": "Pulp Fiction",
"plot": "Un killer si innamora della moglie del suo capo...",
"favorite": "1",
"watchdate": "2022-03-11",
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "1"
},
{
"id": "2",
"title": "Batman",
"plot": "Dal celebre fumetto, le avventurose vicende...",
"favorite": "1",
"watchdate": "2022-04-30",
"rating": "3",
"image": "https://images.unsplash.com/...",
"user": "1"
},
...
]
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(films not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets all favorite films associated with the logged in user.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
[
{
"id": "7",
"title": "Spiderman",
"plot": "Il morso di un ragno mutante dona...",
"favorite": "1",
"watchdate": "2016-02-17",
"rating": "3",
"https://images.unsplash.com/...",
"user": "3"
},
{
"id": "8",
"title": "Iron Man",
"plot": "Dopo essere sopravvissuto ad un attacco...",
"favorite": "1",
"watchdate": "2010-07-22",
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "3"
},
...
]
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(films not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets all best rated films associated with the logged in user.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
[
{
"id": "1",
"title": "Pulp Fiction",
"plot": "Un killer si innamora della moglie del suo capo...",
"favorite": "1",
"watchdate": "2022-03-11",
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "1"
},
...
]
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(films not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets all films seen last month by the logged in user.
Session: req.user to retrieve the logged in user id
HTTP status code 200 OK
[
{
"id": "3",
"title": "Star Wars",
"plot": "Con l'aiuto di robot e altri alleati...",
"favorite": "0",
"watchdate": "2022-05-25",
"rating": "0",
"image": "https://images.unsplash.com/...",
"user": "1"
},
...
]
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(films not found error)HTTP status code 401 Unauthorized
(authentication error)
Gets all films unseen by the logged in user.
HTTP status code 200 OK
[
{
"id": "4",
"title": "Matrix",
"plot": "Esistono due realtà: una è l'esistenza...",
"favorite": "0",
"watchdate": null,
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "2"
},
...
]
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(films not found error)HTTP status code 401 Unauthorized
(authentication error)
Returns a film associated with the logged in user, given the film id.
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve film id
HTTP status code 200 OK
{
"id": "1",
"title": "Pulp Fiction",
"plot": "Un killer si innamora della moglie del suo capo...",
"favorite": "1",
"watchdate": "2022-03-11",
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "1"
}
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(film not found error)HTTP status code 401 Unauthorized
(authentication error)
Creates a new film associated with the logged in user.
Just the title and a rating from 0 to 5 are not optional.
Session: req.user to retrieve the logged in user id
Content-Type: application/json
A JSON object containing the data of the film to insert.
{
"title": "New film to insert",
"plot": "Plot of the film...",
"favorite": "1",
"watchdate": "2022-03-11",
"rating": "5",
"image": "https://images.unsplash.com/...",
"user": "1"
}
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 401 Unauthorized
(authentication error)
Edits a film associated with the logged in user, given the film id.
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve film id
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 404 Not Found
(film not found error)HTTP status code 401 Unauthorized
(authentication error)
Sets or unsets the favorite status for a film asoociated with the logged in user, given the film id.
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve film id
A JSON object containing the new status for the favorite flag.
{
"favorite": "1"
}
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 404 Not Found
(film not found error)HTTP status code 401 Unauthorized
(authentication error)
Changes the rating of a film associated with the logged in user, given the film id.
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve film id
A JSON object containing the new rating for the film.
{
"rating": "4"
}
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 422 Unprocessable Entity
(validation error)HTTP status code 404 Not Found
(film not found error)HTTP status code 401 Unauthorized
(authentication error)
Delete a film associated with the logged in user, given the film id.
Session: req.user to retrieve the logged in user id
Params: req.params.id to retrieve film id
HTTP status code 200 OK
HTTP status code 500 Internal Server Error
(generic server error)HTTP status code 404 Not Found
(film not found error)HTTP status code 401 Unauthorized
(authentication error)