Giter VIP home page Giter VIP logo

movie-list-api-mu's Introduction

Node.js Movies list app

Node.js Awesome MongoDB Mongoose

Server app for Movies list app API

Server

Server is deployed on Heroku    

Database

Database is created on MongoDB Atlas Cloud


Install

$ git clone https://github.com/AyaDesigner/movie-list-api-mu
$ cd movie-list-api-mu
$ npm install

Configure app

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

Running the project

$ npm start

Run the tests

$ npm test

REST API

The REST API to the example app is described below.

Get list of movies saved in database

Request

GET/movies/

curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/movies

Response

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
  },
  ...]

Reload the database with the result from OMDB request

(caution: to be used only in case of emergency, omdb has a limit of 1000 request per day)

Request

GET/movies/reload

curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/movies/reload

Response

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

Search movies by keyword

(keyword can be in the movie's title, director's name or movie's plot)

Request

GET/search

curl -i -H 'Accept: application/json' https://agile-island-00923.herokuapp.com/search?searchKeyword=<KEYWORD>

Response

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
  }
]

Project architecture choices

  • 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

Coming next (a.k.a with more time available)

  • 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

movie-list-api-mu's People

Contributors

ayadotdev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.