Netguru recruitment task solution.
$ git clone https://github.com/d-bend/netguru-recruitment.git
$ cd netguru-recruitment
$ docker-compose up
-
POST /movies
- Allows creating a movie object based on movie title passed in the request body.
- Get your token by sending a POST request to localhost:3000/login. For basic user use:
curl --location --request POST 'localhost:3000/auth' \ --header 'Content-Type: application/json' \ --data-raw '{ "username": "basic-thomas", "password": "sR-_pcoow-27-6PAwCD8" }'
or for premium user
curl --location --request POST 'localhost:3000/auth' \ --header 'Content-Type: application/json' \ --data-raw '{ "username": "premium-jim", "password": "GBLtTyq3E_UNjFnpo9m6" }'
- This application recreates cache after shutdown, to clear cache manually send DELETE request:
curl --location --request DELETE 'localhost:8080/movies' \ --data-raw ''
-
Cache gets wiped automatically via cronjob on first day of the month at 00:00 CET
-
To add a movie for user send a POST request to localhost:8080/movies, movie title should be space-separated:
curl --location --request POST 'localhost:8080/movies' \ --header 'Authorization: Bearer [your token]' \ --header 'Content-Type: application/json' \ --data-raw '{ "title": "The Godfather" }'
-
This application gets the user identity from provided token
-
Change port for /movie by changing PORT variable in docker.env
-
In case this endpoint doesn't work, try providing new api key by changing OMDB_API_KEY variable in docker.env
-
Extra feature! You can supply an optional argument "relevantField" to only get the info about the movie that you want! ex.:
curl --location --request POST 'localhost:8080/movies' \ --header 'Authorization: Bearer [your token]' \ --header 'Content-Type: application/json' \ --data-raw '{ "title": "Django", "relevantFields": { "year": true, "rated": true, "genre": true, "actors": true, "ratings": true } }'
- Look for more options in src/movies/types/available-api-fields.interface.ts
-
GET /movies
- Both basic and premium users have no limits on this route, simply make a request with your token:
curl --location --request GET 'localhost:8080/movies' \ --header 'Authorization: Bearer [your token]' \ --data-raw ''