Giter Club home page Giter Club logo

omdb-wrapper's Introduction

OMDB Wrapper

A Ruby on Rails API that encapsulates the OMbd API search service.

What can my project do?

I create an API REST that encapsulates OMDb API, making it a little more clear how to pass params and what they really are.

I've been studying gem u-case u-case and from the way it worked I had the idea of ​​doing something similar, in a more simplified way. There is a handler that basically encapsulates the entire flow (validation, formatting, request, formatting)

This is good, because every step of the flow can be tested isolated and you can also test the entire flow, and every step obbeys SRP.

This application was deployed to Heroku and has an monitoring application you can check it on https://www.rorvswild.com/applications/1148/, I have sent you a invite to your e-mail to join rorvswild, any trouble on checking it you can message me.

The project is 100% covered by tests, you can get more details of this at /coverage route and has a score of 94.91 at Rubycritic, you can check this by running $ rubycritic

Dependencies

Ruby version

2.6.5p114

Rails version

Rails 6.0.3.4

How to use it

  1. Clone the repository
   $ git clone https://github.com/Instituto-Atlantico/matheus-sales.git
  1. Running with Docker(jump to step 5 if not using docker)
   $ docker-compose build
  1. Starting the server
   $ docker-compose up
  1. Running tests
   $ docker-compose run -e "RAILS_ENV=test" web rake test
  1. Running without docker
   $ bundle install
  1. Run the local server
   $ rails s
  1. For running tests
   $ rake test

Documentation

This API consists of three endpoints they're all explained on this Postman Documentation

API Resources

GET /api/v1/movies/[id]

Example: https://matheus-sales.herokuapp.com/api/v1/movies/tt1130884.json In this endpoint the path param id is required. Response body:

{
  "movie": {
    "id": "tt1130884",
    "title": "Shutter Island",
    "genre": "Mystery, Thriller",
    "year": "2010",
    "director": "Martin Scorsese",
    "type": "movie"
  }
}

GET /api/v1/movies?[title]

Example: https://matheus-sales.herokuapp.com/api/v1/movies?title=Island.json In this endpoint the query param title is required. Response body:

{
  "movie": {
    "id": "tt1130884",
    "title": "Shutter Island",
    "genre": "Mystery, Thriller",
    "year": "2010",
    "director": "Martin Scorsese",
    "type": "movie"
  }
}

GET /api/v1/search?{title,year,type}

Example: https://matheus-sales.herokuapp.com/api/v1/search?title=Island&type=movie.json In this endpoint, the param title is the only required, the others are optional.

Response body:

{
  "movies": [
    {
      "movie": {
        "id": "tt1130884",
        "title": "Shutter Island",
        "year": "2010",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt0399201",
        "title": "The Island",
        "year": "2005",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt3731562",
        "title": "Kong: Skull Island",
        "year": "2017",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt1397514",
        "title": "Journey 2: The Mysterious Island",
        "year": "2012",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt0287717",
        "title": "Spy Kids 2: Island of Lost Dreams",
        "year": "2002",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt0410377",
        "title": "Nim's Island",
        "year": "2008",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt0983946",
        "title": "Fantasy Island",
        "year": "2020",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt0116654",
        "title": "The Island of Dr. Moreau",
        "year": "1996",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt1174730",
        "title": "City Island",
        "year": "2009",
        "type": "movie"
      }
    },
    {
      "movie": {
        "id": "tt9686708",
        "title": "The King of Staten Island",
        "year": "2020",
        "type": "movie"
      }
    }
  ]
}

To improve

  1. Implement a kind of cache, saving the results of requests in a database, making sure that new requests for that same film do not need to hit the OMDb service.
  2. Making a CI / CD for the application, for the sake of time I was unable to study a simple way to do it on GitHub. I even thought about making a pipeline in GitLab that I already have experience in making but I thought it was not so necessary. But it is a point that I will certainly study from the outside, to expand my knowledged.
  3. Because it is somewhat of an external api wrapper it was not a priority for me to implement a performance control tool like NewRelic or Scout, but it would be a point of improvement in the project.
  4. The Handler file contains a repetition of code, with metaprogramming into a single way to declare flow but I think that with that the understanding of flows and how they are assembled would be impaired, a code being complicated to understand to be succinct is a tradeoff that may not be advantageous. But that would be a point of improvement, making the flow with less repetitions and as simple as possible

omdb-wrapper's People

Contributors

matsales28 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.