I am gonna implement a RESTful API that provides the following two basic functionalities to retrieve movie metadata from a content catalogue.
The data used for this comes from two sources:
- To simplify this, we use the static json files in
./movies
as our content catalogue. - OMDb movie metadata can be retrieved as follows:
https://www.omdbapi.com/?i=<imdb movie id>&apikey=<apikey>&plot=full
- use the following API key:
68fd98ab
(Limited to 1000 requests per day) - see https://www.omdbapi.com for details
The first task is to merge movie metadata from our systems with movie metadata from the Open Movie Database (OMDb).
- Calling
GET /api/movies/:id
should return a JSON object representing the merged movie object. :id
is an alphanumeric value that can either refer to OMDb movie ids or our internal ids.- When merging the two objects with the same fields (i.e. both JSON objects have a
title
/Title
), it depends on the name of the field, which metadata should be used. - The following rules apply, with capitalized field names (i.e.
Title
vstitle
) always referring to OMDb dataTitle
overwritestitle
Plot
overwritesdescription
duration
overwritesRuntime
userrating
will become part ofRatings
, applying a similar logic thanRatings
currently hasDirector
,Writer
andActors
should be transformed fromString
to anString[]
- Fields not covered by any of these rules should be merged into the resulting JSON in a normalized way
- If fields are unclear, make reasonable assumptions and choose your implementation accordingly
We want to be able to search movies in our catalogue. To that end, we implement a simple search that returns a movie object if all search terms are true. A search term is a query param in your REST call in the form of <search_field>=<search value>
- If no search term is provided, return all movies
- Search terms are case-insensitive
- Search is performed on the merged json objects of movies
- If
<search_field>
is of typeNumber
orString
in the movie metadata, the search matches if the values are equal, i.e.?title=Sin City
matches3532674.json
- If
<search_field>
is of typeArray
in the movie metadata, the search matches if the<search value>
is contained in the array, i.e.?director=Frank Miller
matches3532674.json
/ the corresponding OMBd object - Calling
GET /api/movies?<search_field>=<search value>
should return a JSON array representing all movies that match the search criteria
In order to compile and run the project, after cloning it from the repository, run the following command:
npm install
This command should be used to launch the application in local-machine.
This command builds compiles ts files to js files and puts them inside build folder.
This command prettifies and checks the source files styling.
This command runs all unit tests and creates code coverage reports inside coverage folder.
You can query data using the following end points:
- http://localhost:8000/api/movies/:id
- http://localhost:8000/api/movies?<search_field>=