limited-effort/snfoil-rails

View on GitHub
lib/generators/snfoil/controller/templates/api_controller.erb

Summary

Maintainability
Test Coverage
# frozen_string_literal: true

class <%= class_modules %><%= class_name %>Controller < SnFoil::Controller::API
  context <%= class_name.singularize %>Context
  serializer <%= class_name.singularize %>JsonapiSerializer
  deserializer <%= class_name.singularize %>JsonapiDeserializer

  # SnFoil::Controller requires current_entity or current_user defined to properly scope
  # all queries, otherwise data leaks could occur
  #
  #  def current_entity
  #  # logic to find authenticated user
  #  end
end