Skip to content

Commit

Permalink
Move APIController to API::ApplicationController
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric committed Jan 9, 2025
1 parent 302ee03 commit 2699911
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module API
class AccreditedProviderSuggestionsController < PublicAPIController
class AccreditedProviderSuggestionsController < ApplicationController
def index
return render_json_error(status: 400, message: I18n.t('accredited_provider_suggestion.errors.bad_request')) if invalid_query?

Expand Down
13 changes: 13 additions & 0 deletions app/controllers/api/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module API
class Controller < ActionController::API
include DfE::Analytics::Requests
include ActionController::HttpAuthentication::Token::ControllerMethods
include Pundit::Authorization

# child must define authenticate method
before_action :authenticate
after_action :verify_authorized
end
end
2 changes: 1 addition & 1 deletion app/controllers/api/public/v1/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class ApplicationController < PublicAPIController
class ApplicationController < ApplicationController
include PagyPagination

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/public/v1/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class CoursesController < API::Public::V1::ApplicationController
class CoursesController < ApplicationController
def index
render jsonapi: paginate(courses),
include: include_param,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class ProviderSuggestionsController < API::Public::V1::ApplicationController
class ProviderSuggestionsController < ApplicationController
def index
return render_json_error(status: 400, message: I18n.t('provider_suggestion.errors.bad_request')) if invalid_query?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Public
module V1
module Providers
module Courses
class LocationsController < API::Public::V1::ApplicationController
class LocationsController < ApplicationController
def index
render jsonapi: locations,
include: include_param,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module API
module Public
module V1
module Providers
class CoursesController < API::Public::V1::ApplicationController
class CoursesController < ApplicationController
def index
render jsonapi: paginate(courses),
include: include_param,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module API
module Public
module V1
module Providers
class LocationsController < API::Public::V1::ApplicationController
class LocationsController < ApplicationController
def index
render jsonapi: locations,
include: include_param,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/public/v1/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class ProvidersController < API::Public::V1::ApplicationController
class ProvidersController < ApplicationController
def index
render jsonapi: paginate(providers),
include: params[:include],
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/public/v1/subject_areas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class SubjectAreasController < API::Public::V1::ApplicationController
class SubjectAreasController < ApplicationController
def index
render(
jsonapi: SubjectArea.active.includes(subjects: [:financial_incentive]),
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/public/v1/subjects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module API
module Public
module V1
class SubjectsController < API::Public::V1::ApplicationController
class SubjectsController < ApplicationController
def index
subjects = Subject.active.includes(:financial_incentive)

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/school_suggestions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module API
class SchoolSuggestionsController < PublicAPIController
class SchoolSuggestionsController < ApplicationController
def index
return render_json_error(status: 400, message: I18n.t('school_suggestion.errors.bad_request')) if invalid_query?

Expand Down
11 changes: 0 additions & 11 deletions app/controllers/api_controller.rb

This file was deleted.

0 comments on commit 2699911

Please sign in to comment.