Used to obtain the jwt token, which is an authentication method used by this API. JWT must be supplid with every request to protected endpoints: /movies
in the Autorization
header
body: {
username: String, // user's username used to login
password: String // user's password used to login
}
token: {
[TOKEN] // token with encoded user's data
}
invalid username or password
the user's data was not found in the database, try checking the spelling of either username or password
Upload a new movie to the movies database. Provide movie title in the request's body, and the API will automatically find it on the OMDB and add any additional information.
headers: {
Authorization: Bearer [TOKEN] // token obtained on login
}
body: {
title: String // title of the movie we want to add to our database
}
{
"id": 123,
"title": "Mission: Impossible - Ghost Protocol",
"year": "2011",
"genre": "Action, Adventure, Thriller",
"director": "Brad Bird",
"createdAt": "2022-01-17T11:41:24.795Z",
"_id": "XqF1rIUbp9iBM3j2"
}
invalid token
provided token is invalid or expired, try re-logging to the application to get a new token
missing authorization header
authorization header was not found in the request
You have reached your limit of 5 movies
user's role doesn't allow to upload more than 5 movies per month, try upgrading the account from 'basic' to 'premium'
You already have this movie
movie with this title is already in the database, try changing the title or be more specific
Movie not found
movie was not found in the OMDB databse, try searching up a different movie
Used to get all the movies uploaded by the currently logged-in user.
headers: {
Authorization: Bearer [TOKEN] // token obtained on login
}
[
{
"id": 123,
"title": "Elko",
"year": "2012",
"genre": "Short, Drama",
"director": "Alexander Yan",
"createdAt": "2022-01-17T11:52:10.004Z",
"_id": "Mbfb8rquFttfp3b1"
},
{
"id": 123,
"title": "Mission: Impossible - Ghost Protocol",
"year": "2011",
"genre": "Action, Adventure, Thriller",
"director": "Brad Bird",
"createdAt": "2022-01-17T11:41:24.795Z",
"_id": "XqF1rIUbp9iBM3j2"
},
]
invalid token
-||-
missing authorization header
-||-
- Clone this repository
- Run from root dir
npm install
JWT_SECRET=secret APP_PORT=8080 docker-compose up -d
To stop the authorization service run
docker-compose down
- Node.js
- Express.js
- NeDB (simulating MongoDB)
- Jest.io
- Axios