sample api in express that should return some simple movie recommendation. just to practice creating a rest api for movies.
- install the dependencies:
npm ci
- run the service:
npm run monitor
- I added a linter to keep the feel of the code the same
- you can run the linter via
npm run lint
- there are some for loops that need cleaning
- you can run the linter via
- there are unit tests for the controller and integration test for the api as a whole
- you can run them via
npm test
- you can run them via
- you should be able to run a simple curl to retrieve information from the service
- retrieve multiple entries:
curl --location --request GET 'http://127.0.0.1:5000'
- retrieve entries using filters like
genre
andtime
- examples
curl --location --request GET 'http://127.0.0.1:5000?time=18:00:00&genre=Drama'
curl --location --request GET 'http://127.0.0.1:5000?time=07:00:00&genre=Action%20&%20Adventure'
http://127.0.0.1:5000?genre=animation
- assumption:
- the time param in the filter is assumed to be in GMT +11:00
- it might be helpful if we control that in the front end but some sanitation and cleaning might help
- the idea is just to return movies based on those that are showing after the time you entered
- it is assume that certain special characters would be encoded
- validation
- time is checked if it can be converted properly into a moment object
- the service does not have an writeable persistence layer.
- the repo basically just retrieves from pastebin or uses a flat json for data
- the repositories should contain actual implementation to manage data persistence
- ie: fetching and querying from a db of sorts.
- the service uses port 5000 but you can change the configuration in
config/index.js
- the utility files/classes are in the helpers directory. these are helpful for just managing logging and responses in general.
- refactor code to agree with linting
- add more negative tests
- add in integration test for the single retrieval call
- add some other routes to simulate other services or perhaps use a separate branch
- actually implement pagination but with no big dataset it is a nice to have