Server app for Movies list app API
Server is deployed on Heroku
Database is created on MongoDB Atlas Cloud
$ git clone https://github.com/AyaDesigner/movie-list-api-mu
$ cd movie-list-api-mu
$ npm install
Create .env
file in the root folder of the project. Then edit it with your settings. You will need:
- OMDB_API_KEY = Your OMDB api key
- MONGODB_URI = Mongo db url
$ npm start
$ npm test
The REST API to the example app is described below.
GET/movies/
curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/movies
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 3596
Etag: W/"e0c-1VUapPDHsZmDz7kNNETPlb8WZfk"
Date: Mon, 21 Jun 2021 17:21:13 GMT
Via: 1.1 vegur
[
{
"_id": "60d07b5becdd3300220a6a87",
"imdbID": "tt0808240",
"Title": "Turks in Space",
"Director": "Kartal Tibet",
"Plot": "A family of Turks try to adapt to life in a new solar system.",
"Poster": "https://m.media-amazon.com/images/M/MV5BMTYwOTMwODIxNF5BMl5BanBnXkFtZTcwMjc0NzA0MQ@@._V1_SX300.jpg",
"createdAt": "2021-06-21T11:43:23.651Z",
"updatedAt": "2021-06-21T11:43:23.651Z",
"__v": 0
},
{
"_id": "60d07b5becdd3300220a6a88",
"imdbID": "tt0482603",
"Title": "Space Chimps",
"Director": "Kirk DeMicco",
"Plot": "Three chimps are sent into space to explore the possibility of alien life when an unmanned space shuttle crash lands on an uncharted planet.",
"Poster": "https://m.media-amazon.com/images/M/MV5BNDU0MDY1OTQzOV5BMl5BanBnXkFtZTcwNzQ3ODI3MQ@@._V1_SX300.jpg",
"createdAt": "2021-06-21T11:43:23.652Z",
"updatedAt": "2021-06-21T11:43:23.652Z",
"__v": 0
},
...]
(caution: to be used only in case of emergency, omdb has a limit of 1000 request per day)
GET/movies/reload
curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/movies/reload
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 3596
Etag: W/"e0c-1VUapPDHsZmDz7kNNETPlb8WZfk"
Date: Mon, 21 Jun 202
(keyword can be in the movie's title, director's name or movie's plot)
GET/search
curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/search?searchKeyword=<KEYWORD>
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 3596
Etag: W/"e0c-1VUapPDHsZmDz7kNNETPlb8WZfk"
Date: Mon, 21 Jun 202
[
{
"_id": "60ce21f12cf4d143ba8bb2ff",
"imdbID": "tt2632184",
"Title": "Super Hero Taisen Z: Kamen Rider vs. Super Sentai vs. Space Sheriff",
"Director": "Osamu Kaneda",
"Plot": "A new evil organization known as Space Shocker, which are led by the magic-using Space Ikadevil and Space Spider Man, threatens the Earth by causing an unknown phenomenon. The Space ...",
"Poster": "https://m.media-amazon.com/images/M/MV5BN2Y5YTEwNTQtYjI2MC00YzRhLWIwMTktYmJkNmFmYWMyN2QyXkEyXkFqcGdeQXVyMjM5ODMxODc@._V1_SX300.jpg",
"createdAt": "2021-06-19T16:57:21.004Z",
"updatedAt": "2021-06-19T16:57:21.004Z",
"__v": 0
}
]
- Separation of business logic from the API routes
- Separation of business logic from the database access
- Services layer usage
- Using another layer for third-party services calls
- Unit test
- Promises usage
- Add unit tests (only omdb-client test has been created) for each service and route
- Better handling of the errors
- Add filtering and pagination when returning movies