Giter VIP home page Giter VIP logo

apicasso's Introduction

Gem Version Docs Coverage Maintainability codecov

Create APIs in a fast and dynamic way, without the need to develop everything from scratch. You just need to create your models and let APIcasso do the rest for you. It is the perfect candidate to make your project development go faster or for legacy Rails projects that do not have an API.

If you think it through, JSON API development can get boring and time consuming. Every time you use almost the same route structure, pointing to the same controller actions, with the same ordering, filtering and pagination features.

APIcasso is intended to be used to speed-up development, acting as a full-fledged CRUD JSON API into all your models. It is a route-based abstraction that lets you create, read, list, update or delete any ActiveRecord object in your application. This makes it possible to make CRUD-only applications just by creating functional Rails' models. Access to your application's resources is managed by a .scope JSON object per API key. It uses that permission scope to restrict and extend access.

You can make your own API with only 4 steps:

Step 1

Create your models

Step 2

Insert APIcasso engine into your routes and run the installation command

Step 3

Create an Apicasso::Key

Step 4

Profit! 👑 Consume your REST API

Installation

Add this line to your application's Gemfile:

gem 'apicasso'

And then execute this to generate the required migrations:

$ bundle install && rails g apicasso:install

Requirements

  • PostgreSQL with JSON columns support
  • Ruby 2.3+
  • Rails 5+

Usage

APIcasso is meant to be used as an engine, which means you don't need to configure any route or controller to build a working CRUD API. Sometimes you also need some customized controller actions or even a specific logic to access some of your application's resources. In that case you will use Apicasso::CrudController class to easily build only your own logic around the API abstraction.

Mounting engine into config/routes.rb

After installing it, you can mount a full-fledged CRUD JSON API just by attaching into some route. Usually you will have it under a scoped route like /api/v1 or a subdomain. You can do that by adding this into your config/routes.rb:

  # To mount your APIcasso routes under the path scope `/api/v1`
  mount Apicasso::Engine, at: "/api/v1"
  # or, if you prefer subdomain scope isolation
  constraints subdomain: 'apiv1' do
    mount Apicasso::Engine, at: "/"
  end

Your API will reflect very similarly a resources :resource statement with the following routes:

  get '/:resource/' # Index action, listing a `:resource` collection from your application
  post '/:resource/' # Create action for one `:resource` from your application
  get '/:resource/:id' # Show action for one `:resource` from your application
  patch '/:resource/:id' # Update action for one `:resource` from your application
  delete '/:resource/:id' # Destroy action for one `:resource` from your application
  get '/:resource/:id/:nested/' # Index action, listing a collection of a `:nested` relation from one of your application's `:resource`
  options '/:resource/' # A schema dump for the required `:resource`
  options '/:resource/:id/:nested/' # A schema dump for the required `:nested` relation from one of your application's `:resource`

This means all your application's models will be exposed as :resource and it's relations will be exposed as :nested. It will enable you to CRUD and get schema metadata from your records.

Extending base API actions

When your application needs some kind of custom interaction that is not covered by APIcasso's CRUD approach you can make your own actions using our base classes and objects to go straight into your logic. If you have built the APIcasso's engine into a route it is important that your custom action takes precedence over the gem's ones. To do that you need to declare your custom route before the engine on you config/routes.rb

  match '/:resource/:id/a-custom-action' => 'custom#not_a_crud', via: :get
  mount Apicasso::Engine, at: "/api/v1"

And in your app/controllers/custom_controller.rb you would have something like:

  class CustomController < Apicasso::CrudController
    def not_a_crud
      render json: @object.some_operation
    end
  end

This way you enjoy all our object finder, authorization and authentication features, making your job more straight into your business logic.

CORS

APIcasso comes with a permissive CORS configuration out of the box. But you can make your own by editting the config/initializers/apicasso.rb file, which is created at the installation proccess. The file comes with some descriptive comments and all configuration is based on Rack CORS options.

Authentication

But exposing my models to the internet is permissive as hell! Haven't you thought about security?

Sure! The APIcasso suite is exposing your application using authentication through Authorization: Token HTTP header authentication. The API key objects are manageable through the Apicasso::Key model, which gets setup at install. When a new key is created a .token is generated using an Universally Unique Identifier(RFC 4122). An authenticated request looks like this:

curl -X GET \
  https://apixample.com/v1/your_app_resource \
  -H 'authorization: Token token=cda4e9f633c123ef9ddce5e6564292b3'

Each Apicasso::Key object has a token attribute, which is used on this header to authorize access. For now, there is no plans for a login/JWT logic, you should implement this in your project's scope.

Authorization

Your Models are then exposed based on each Apicasso::Key.scope definition, which is a way to configure how much of your application each key can access. I.E.:

  Apicasso::Key.create(scope:
                        { manage:
                            { order: true, user: { account_id: 1 } },
                          read:
                            { account: { manager_id: 1 } }
                        })

The key from this example will have full access to all orders and to users with account_id == 1. It will have also read-only access to accounts with id == 1.

A scope configured like this translates directly into which kind of access each key has on all of your application's models. This kind of authorization is why one of the dependencies for this gem is CanCanCan, which abstracts the scope field into your API access control.

You can have two kind of access control:

  • true - This will mean the key will have the declared clearance on ALL of this model's records
  • Hash - This will build a condition to what records this key have access to. A scope as { read: [{ account: { manager_id: 1 } }] } will have read access into accounts with manager_id == 1

This saves you the trouble of having to setup every controller for each model. And even if your application really needs it, just make your controllers inherit from Apicasso::CrudController extending it and enabling the use of @object and @resource variables to access what is being resquested.

Features on index actions

The index actions present in the gem are already equipped with pagination, ordering, grouping, fieldset selection and filtering. This will save you a lot of trouble, adding some best-practices conventions into your application's API.

Sort

You can sort a collection query by using a URL parameter with field names preffixed with + or - to configure custom ordering per request.

To order a collection with ascending updated_at and descending name you can add the sort parameter with those fields as options, indicating which kind of ordination you want to give to each one:

?sort=+updated_at,-name

Filtering/Search

APIcasso has ransack's search matchers on it's index actions. This means you can dynamically build search queries with any of your resource's fields, this will be done by using a ?q parameter which groups all your filtering options on your requests. If you wanted to search all your records and return only the ones with full_name starting with Picasso your query would look something like this:

?q[full_name_start]=Picasso

To build complex search queries you can chain many parameter options or check ransack's wiki on how to adapt this feature into your project's needs.

Pagination

Automatic pagination is done in index actions, with the adittion of some metadata to help on the data consumption. You can pass page and per page parameters to build pagination options into your needs. And on requests that you need unpaginated collections, just pass a lower than zero per_page. Example of a pagination query string:

?page=2&per_page=12

Your colletion will be build inside a JSON along with some metadata about it. The response structure is:

{ entries: [{Record1}, {Record2}, {Record3} ... {Record12}],
  total: 1234,
  total_pages: 102,
  last_page: false,
  previous_page: localhost:3000/my_records?page=1&per_page=12,
  next_page: localhost:3000/my_records?page=3&per_page=12,
  out_of_bounds: false,
  offset: 12 }

Fieldset selecting

Sometimes your data can grow large in some tables and you need to consumed only a limited set of data on a given frontend application. To avoid large requests and filtering a lot of unused data with JS you can restrict which fields you need on your API's reponse. This is done adding a ?select parameter. Just pass the field names you desire splitted by , Let's say you are building a user list with their name, e-mails and phones, to get only those fields your URL query would look something like:

?select=name,email,phone

This will change the response to return only the requested attributes. You need to observe that your business logic may require some fields for a valid response to be returned. This method can be used both on index and show actions

Including relations or methods on response

If there is any method or relation that you want to be inserted on the payload, you just need to pass them as a part of the URL query like this:

?include=pictures,suggestions

This will insert the contents of .pictures and .suggestions on the payload, along with the records' data. This means you can populate the payload both with methods or relations contents. This method can be used both on index and show actions

Grouping operations

If you need to make grouping calculations, like:

  • Counting of all records, or by one optional field presence
  • Maximum value of one field
  • Minimum value of one field
  • Average value of one field
  • Value sum of one field

Grouping is done by the combination of 3 parameters

?group[by]=a_field&group[calculate]=count&group[fields]=another_field

Each of those attributes on the ?group parameter represent an option of the query being made.

  • group[by] - Represents which field will be the key for the grouping behavior
  • group[calculate] - Which calculation will be sent in the response. Options are: count, maximum, minimum, average, sum
  • group[field] - Represents which field will be the base for the response calculation.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ErvalhouS/APIcasso. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. To find good places to start contributing, try looking into our issue list and our Codeclimate profile, or if you want to participate actively on what the core team is working on checkout our todo list:

TODO

  • Add support to other databases
  • Add gem options like: Token rotation, Alternative authentication methods
  • Refine and document auto-documentation feature
  • Rate limiting

Code of conduct

Everyone interacting in the APIcasso project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

apicasso's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

abinoam

apicasso's Issues

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Sort por atributos aninhados

Seria interessante que se pudesse fazer a ordenação de um elemento pela chave de um elemento hash filho dele, por exemplo

used_model: {profile_image: {url: nil}}

Então o sort poderia ser assim

{{url}}/{{api_base}}/used_models?q[active_eq]=true&sort=-profile_image.url

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Default fields to be on responses

It would be nice to somehow register the default fields that should be on response for each resource.
This would avoid repetitive includes and decrease the payload.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Adapt comments into RDoc convention

We already have an OK documentation present on the comments across the projects' files. This is fine, but RDoc pages are being generated with poorly formatted examples and some of the examples across the code are not being placed where it should.

This is very visible at our Ability docs, which has fine examples, but they are very badly placed. Other examples are being poorly formatted, like the ones on the CRUD Controller endpoints.

This should be fixed for a better documentation.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Adicionar no escopo includes de relacionamento entre tabelas

Por exemplo, eu só posso acessar os seminovos de uma determinada Conta, mas eu só tenho relação com a conta através do unidade a qual o seminovo pertence, no entanto unidades para Conta são dinâmicas, pode ser adicionadas ou removidas, de forma que eu não posso colocar por exemplo:

{used_model=>{unit_id=>[1,2,3]}}

Porque em algum momento pode surgir uma unidade de id 4, ai eu vou precisar de adicionar no escopo manualmente.

Seria interessante algo como:

{used_model=>{unit=>{accout_id=>1}}}

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

CORS is poorly customizable

The CORS approach in the gem is not configurable at all. In an ideal approach it should use rack-cors as a middleware injected into the engine with configurable variables. Those variables should be available as initializer configuration and a base file should be generated through the install generator of the gem.

Interesting benchmark for a method to generate an initializer on install task:
https://github.com/plataformatec/devise/blob/715192a7709a4c02127afb067e66230061b82cf2/lib/generators/devise/install_generator.rb#L16

Interesting benchmark for a default initializer with a lot of examples and cool coments with the available options:
https://github.com/plataformatec/devise/blob/715192a7709a4c02127afb067e66230061b82cf2/lib/generators/templates/devise.rb

Interesting benchmark for a default permissive CORS configuration:
https://glaucocustodio.github.io/2016/01/20/dont-forget-to-expose-headers-when-using-rack-cors/

The CORS configuration should not be limited to the variables contained only on this benchmark. All configurable variables contained on rack-cors should be configurable.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Sort com opção sem sensitive case

Seria interessante ter uma opção na ordenação que determinasse que a ordenação não fosse sensitive case, para que coisas como a e A fiquem juntos.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Problems with nested resources and custom queries

I've been performing queries from the endpoint without nested_resources and it worked fine, but when I've tried to perform them with nested_resources I couldn't make it work.
I got this error:

NoMethodError in Apicasso::CrudController#nested_index

undefined method `incidence_trackings' for #<Incidence:0x007efe1810bea0> Did you mean? incidence_tracking incidence_tracking= incidence_tracking_ids incidence_tracking_ids=

This is the endpoint that I tested:

http://localhost:3000/api/v1/incidences/1/incidence_trackings

I need to perform a custom query so the API returns the expected results; I've been reading your documentation and there is a section called "Extending base API actions", which I've tried and couldn't make it work. In this case that didn't work I got the BadRequest error (Bad hacker, stop bullying or I'll tell your mom!).

It seems that I need an id and a nested_resource.

I've tried using any id from my resource, even if I don't need it, and it doesn't work either.
This is the endpoint that I tested:

http://localhost:3000/api/v1/incidences/1/custom

Processing by Apicasso::CrudController#nested_index as */*
  Parameters: {"resource"=>"incidences", "id"=>"2", "nested"=>"custom"}
Completed 400 Bad Request in 1ms (ActiveRecord: 0.0ms)

Can I make an endpoint which doesn't require an id with a custom query.

This is my code:

routes.rb

Rails.application.routes.draw do

  match '/:resource/:id/custom' => 'apicustom#custom', via: :get
  mount Apicasso::Engine, at: "/api/v1"

end

api_controller.rb

class ApiController < ApplicationController
  Apicasso::Key.create(scope:
                           { read:
                                 {
                                   incidence: true,
                                   phone_identifier: true,
                                   interest_point: true,
                                   incidence_type: true,
                                   incidence_tracking: true
                                 },
                             create:
                                 {
                                   incidence: true,
                                   phone_identifier: true
                                 }
                           })
  end

apicustom_controller.rb

class ApicustomController < Apicasso::CrudController

  def custom
    render json: Incidence.find_by_sql("SELECT inc.id, inc.image_url, inc.description, it.status
                                        FROM incidences inc, (SELECT id, status, date, incidence_id
                                                              FROM incidence_trackings it1
                                                              WHERE date = (SELECT MAX(date)
                                                                            FROM incidence_trackings it2
                                                                            WHERE it1.incidence_id = it2.incidence_id)) it
                                        WHERE inc.id = it.incidence_id;")

  end

end

Thanks for your time.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot couldn't find a requirements.txt for this project

Dependabot couldn't find a requirements.txt for this project.

Dependabot requires a requirements.txt to evaluate your project's current Python dependencies. It had expected to find one at the path: /requirements.txt.

If this isn't a Python project, or if it is a library, you may wish to disable updates for it from within Dependabot.

You can mention @dependabot in the comments below to contact the Dependabot team.

Add throttling options

Suggestion is to adopt a Rack Attack configuration that allows to control request limiting per Apicasso::Key.

This project was designed to have this feature implemented based on JSON rule present on the .request_limit field on all Apicasso::Key object. The suggested format is:

{
  limit: # AN ALL AROUND REQUEST LIMITING,
  period: # AN ALL AROUND PERIOD FOR REQUEST THROTTLING,
  <% paths.each do |path| %>
    <%= path %>: {
      limit: # A REQUEST LIMITING FOR A SPECIFIC PATH,
      period: # A PERIOD FOR REQUEST THROTTLING FOR A SPECIFIC PATH
    }
  <% end %>
}

Please note this code example is just for the sake of explanation. This would make APIcasso have global and per-path request limiting, all based on which key is being used for the request. A feature like this would enable for API monetizing based on request quota selling

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Support to other Databases

The project has PostgreSQL as a requirement because JSON columns are used, both on Apicasso::Key and Apicasso::Request. When using other DBs this is achievable through AR serialization and a common text field.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "url":
  In Gemfile:
    codecov was resolved to 0.1.14, which depends on
      url

Could not find gem 'url', which is required by gem 'codecov', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

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.