Giter Site home page Giter Site logo

ilyessagg / denzel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from corentindieudonne/denzel

0.0 1.0 0.0 44 KB

Web Application Project n°2 : 📽️ API of the must-watch Denzel's movies (March 2019)

Home Page: https://esilv-denzel.now.sh

Makefile 7.53% JavaScript 64.65% CSS 2.30% HTML 25.52%
api rest-api graphql-api javascript

denzel's Introduction

DENZEL

The must-watch Denzel's movies

REST API : https://ilyessagg-denzel.glitch.me

denzel

Table of Contents

🐣 Introduction

Denzel Washington is one of my favorite actor.

He won 2 Oscars. Another 82 wins & 166 nominations

🎯 Objectives

Build a REST and GRAPHQL API to get the must-watch Denzel's movies.

👩‍💻 Just tell me what to do

  1. Fork the project via `github`

    fork

  2. Clone your forked repository project `https://github.com/YOUR_USERNAME/denzel`
    cd /path/to/workspace
    ❯ git clone [email protected]:YOUR_USERNAME/denzel.git
  3. Do things
  4. Commit and push your different modifications
    cd /path/to/workspace/denzel
    ❯ git add -A && git commit -m "feat(movies): get a random movie"
    ❯ git push origin master

Note:

🏃‍♀️ Steps to do

Definition and Configuration

  • A must-watch movie is a movie with a metascore higher than 70.
  • API should listen locally the port 9292.
  • Data should be stored in MongoDB. Backed either with a DaaS: mLab, MongoDB Atlas etc... Either with a container Docker.
  • To test and check your API, you should use a client like Insomnia or Postman

REST endpoints to implement

GET /movies/populate

Populate the database with all the Denzel's movies from IMDb.

You could use the src/imdb.js ready-to-use exported function.

❯ curl -H "Accept: application/json" http://localhost:9292/movies/populate
{
  "total": 56
}

Start node sandbox.js for an usage example.

GET /movies

Fetch a random must-watch movie.

❯ curl -H "Accept: application/json" http://localhost:9292/movies
{
  "id": "tt0765429",
  "link": "https://www.imdb.com/title/tt0765429/?ref_=nm_flmg_act_13",
  "metascore": 76,
  "poster": "https://m.media-amazon.com/images/M/MV5BMTkyNzY5MDA5MV5BMl5BanBnXkFtZTcwMjg4MzI3MQ@@._V1_UY268_CR4,0,182,268_AL_.jpg",
  "rating": 7.8,
  "synopsis": "An outcast New York City cop is charged with bringing down Harlem drug lord Frank Lucas, whose real life inspired this partly biographical film.",
  "title": "American Gangster (2007)",
  "votes": 362.951,
  "year": 2007
}

GET /movies/:id

Fetch a specific movie.

❯ curl -H "Accept: application/json" http://localhost:9292/movies/tt1907668
{
  "id": "tt1907668",
  "link": "https://www.imdb.com/title/tt1907668/?ref_=nm_flmg_act_7",
  "metascore": 76,
  "poster": "https://m.media-amazon.com/images/M/MV5BMTUxMjI1OTMxNl5BMl5BanBnXkFtZTcwNjc3NTY1OA@@._V1_UX182_CR0,0,182,268_AL_.jpg",
  "rating": 7.3,
  "synopsis": "An airline pilot saves almost all his passengers on his malfunctioning airliner which eventually crashed, but an investigation into the accident reveals something troubling.",
  "title": "Flight (2012)",
  "votes": 299.625,
  "year": 2012
}

GET /movies/search

Search for Denzel's movies.

This endpoint accepts the following optional query string parameters:

  • limit - number of movies to return (default: 5)
  • metascore - filter by metascore (default: 0)

The results array should be sorted by metascore in descending way.

❯ curl -H "Accept: application/json" http://localhost:9292/movies/search?limit=5&metascore=77
{
  "limit": 5,
  "results": [
  {
    "id": "tt2671706",
    "link": "https://www.imdb.com/title/tt2671706/?ref_=nm_flmg_act_3",
    "metascore": 79,
    "poster": "https://m.media-amazon.com/images/M/MV5BOTg0Nzc1NjA0MV5BMl5BanBnXkFtZTgwNTcyNDQ0MDI@._V1_UX182_CR0,0,182,268_AL_.jpg",
    "rating": 7.2,
    "synopsis": "A working-class African-American father tries to raise his family in the 1950s, while coming to terms with the events of his life.",
    "title": "Fences (2016)",
    "votes": 84.291,
    "year": 2016
  },
  {
    "id": "tt0115956",
    "link": "https://www.imdb.com/title/tt0115956/?ref_=nm_flmg_act_31",
    "metascore": 77,
    "poster": "https://m.media-amazon.com/images/M/MV5BODJlOTlkNzUtN2U2OC00NWUxLTg3MjgtNGVmZGU5ZTk0ZjM4XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_UX182_CR0,0,182,268_AL_.jpg",
    "rating": 6.6,
    "synopsis": "A U.S. Army officer, despondent about a deadly mistake he made, investigates a female chopper commander's worthiness for the Medal of Honor.",
    "title": "À l'épreuve du feu (1996)",
    "votes": 46.271,
    "year": 1996
  },
  {
    "id": "tt0112857",
    "link": "https://www.imdb.com/title/tt0112857/?ref_=nm_flmg_act_32",
    "metascore": 78,
    "poster": "https://m.media-amazon.com/images/M/MV5BNjI3NjFiNmMtMmQ1ZC00OTUwLWJlMWMtM2UxY2M2NDQ0OWJhXkEyXkFqcGdeQXVyNTI4MjkwNjA@._V1_UX182_CR0,0,182,268_AL_.jpg",
    "rating": 6.7,
    "synopsis": "An African-American man is hired to find a woman, and gets mixed up in a murderous political scandal.",
    "title": "Le diable en robe bleue (1995)",
    "votes": 15.686,
    "year": 1995
  }],
  "total": 3
}

POST /movies/:id

Save a watched date and a review.

This endpoint accepts the following post parameters:

  • date - the watched date
  • review - the personal review
❯ curl -X POST -d '{"date": "2019-03-04", "review": "😍 🔥"}' -H "Content-Type: application/json" http://localhost:9292/movies/tt0328107
{
  "_id": "507f191e810c19729de860ea"
}

GraphQL endpoints to implement

Same definitions as REST API with /graphql endpoint.

  • Populate the database
  • Fetch a random must-watch movie
  • Fetch a specific movie
  • Search for Denzel's movies
  • Save a watched date and a review.

(A suggested) Schema

schema {
  query Query
}

type Query {
  movies: [Movie]
  movie: Movie
}

type Movie {
  link: String
  metascore: Int
  synopsis: String
  title: String
  year: Int
}
❯ curl -d '{"query": "movie {link metascore synopsis title year}"}' -H "Content-Type: application/json" http://localhost:9292/graphql
{
  "data": {
    "movie": {
      "link": "https://www.imdb.com/title/tt0174856/?ref_=nm_flmg_act_23",
      "metascore": 74,
      "synopsis": "The story of Rubin \"Hurricane\" Carter, a boxer wrongly imprisoned for murder, and the people who aided in his fight to prove his innocence.",
      "title": "Hurricane Carter (1999)",
      "year": 1999
    }
  }
}

Bonus - The Client side

Build a client side web application.

The MVP definiton could be:

Each time, we open the web application or refresh the page, fetch a random must-watch movie and

  • display the title
  • display the synopsis
  • display the cover
  • display the metascore
  • display the review
  • allow to open the IMDb record

🛣️ Related course

Licence

Uncopyrighted

denzel's People

Contributors

ilyessagg avatar 92bondstreet avatar

Watchers

James Cloos 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.