for this project to work it is necessary to provide some key values in the .env file (if running locally)
Parameter | Type | Description |
---|---|---|
API_PORT |
string |
Required. Port where the API will run |
TOKEN_KEY |
string |
Required. key to validate the jwt token |
REFRESH_TOKEN_KEY |
string |
Required. key to validate the jwt refresh token |
DB_URL |
string |
Required. Atlas MongoDB url |
POST /register
Parameter | Type | Description | from |
---|---|---|---|
first_name |
string |
Required. User first name | body |
last_name |
string |
Required. User last name | body |
email |
string |
Required. User email | body |
password |
string |
Required. User password | body |
admin |
string |
default: false. Specified when creating an administrator account | body |
Responses
- 400 -
"All inputs are required"
- 409 -
"User already exists"
- 201 - User information generated in object format :
{
"first_name": first name provided by user,
"last_name": last name provided by user,
"email": email provided by user,
"password": hashed password provided by user,
"admin": false by default,
"_id": id generated in mongoDB,
"__v": 0,
"token": jwt access token generated and stored in bearer header
}
POST /login
Parameter | Type | Description | from |
---|---|---|---|
email |
string |
Required. User email | body |
password |
string |
Required. User password | body |
Responses
- 400 -
"Invalid email or password"
- 401 -
"Invalid token"
- 200 - User information stored in database :
{
"_id": user mongoDB id,
"first_name": first name,
"last_name": last name,
"email": user email,
"password": user hashed password,
"admin": false by default,
"__v": 0,
"token": access token
}
GET /:id
Parameter | Type | Description | from |
---|---|---|---|
id |
string |
Required. User id | req.params |
token |
string |
Required. User access token | bearer Header |
Responses
- 400 -
"Cannot find user"
- 401 -
"Invalid token"
- 200 - User information stored in database :
{
"_id": mongoDB id,
"first_name": user first name,
"last_name": user last name,
"email": email,
"password": hashed password,
"admin": false by default,
"__v": 0
}
DELETE /:id
Parameter | Type | Description | from |
---|---|---|---|
id |
string |
Required. User id | req.params |
token |
string |
Required. User access token | bearer Header |
Responses
- 400 -
"generic error"
- 401 -
"Invalid token"
- 200 -
"User successfully deleted"
PUT /:id
send the parameter that the user intent to change
Parameter | Type | Description | from |
---|---|---|---|
first_name |
string |
Optional User first name | body |
last_name |
string |
Optional User last name | body |
email |
string |
Optional User email | body |
password |
string |
Optional User password | body |
admin |
string |
Optional Specified when creating an administrator account | body |
token |
string |
Optional User access token | bearer Header |
Responses
- 400 -
"generic error"
- 401 -
"Invalid token"
,"You are not allowed to do this"
- 200 - It will return an object with the information of the user already updated :
{
"first_name": first name provided by user,
"last_name": last name provided by user,
"email": email provided by user,
"password": hashed password provided by user,
"admin": false by default,
"_id": id generated in mongoDB,
"__v": 0,
}
GET /logout
Responses
- 400 -
"generic error"
- 200 -
"Successfully loged out user"
, set the access token to empty string in header
GET /all-users
Responses
- 400 -
"generic error"
- 401 -
"Invalid token"
,"You are not allowed to see this request"
- 200 - It will return all users stored in database in object format
POST /register-movie
Parameter | Type | Description | from |
---|---|---|---|
movieName |
string |
Optional User first name | body |
releasedYear |
string |
Optional User last name | body |
description |
string |
Optional User email | body |
movieGenre |
string |
Optional User password | body |
access token | string |
Reequired User password | bearer header |
Responses
- 400 -
"generic error"
- 401 -
"Invalid token"
,"You are not allowed to see this request"
- 200 - Created movie :
{
"name": Movie name provided by the user,
"released_year": Movie released year provided by the user,
"synopsis": Movie description provided by the user,
"genre": Movie genre provided by the user,
"_id": Movie id generated in MongoDB,
"__v": 0,
"uploadedBy": user id
}
GET /catalog/:id
Parameter | Type | Description | from |
---|---|---|---|
id |
string |
Required Movie id | req.params |
token |
string |
Required User access name | bearer Header |
Responses
- 400 -
"Cannot find movie"
- 401 -
"Invalid token"
,"You are not allowed to see this request"
- 200 - Movie content :
{
"_id": Movie id,
"name": Movie name,
"released_year": Movie release year,
"synopsis": Movie description,
"genre": Movie genre,
"__v": 0,
"uploadedBy": id from User that uploaded the Movie
}
GET /catalogo
Parameter | Type | Description | from |
---|---|---|---|
token |
string |
Required User access name | bearer Header |
Responses
- Unable to finish this request