Skip to content

Commit

Permalink
Merge pull request #224 from plural/normalize-user-endpoint
Browse files Browse the repository at this point in the history
Return a normal JSONAPI response for user endpoint.
  • Loading branch information
plural authored Dec 29, 2023
2 parents d72aa24 + 5dcb1be commit 4ea248d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/api/v3/private/user_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module API
module V3
module Private
class Api::V3::Private::UserController < ::ApplicationController
class Api::V3::Private::UserController < JSONAPI::ResourceController
include JwtAuthorizationConcern

def index
render json: { username: @current_user.id }
def context
{current_user: @current_user, params: params}
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/resources/api/v3/private/user_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Api::V3::Private::UserResource < JSONAPI::Resource
key_type :string

paginator :none

exclude_links :default
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Don't generate links or relationship routes for decks.
jsonapi_resources :decks do
end
resources :user, only: [:index]
jsonapi_resources :user, only: [:index, :show]
end
namespace :public, defaults: { format: :json } do
jsonapi_resources :card_cycles, only: [:index, :show]
Expand Down

0 comments on commit 4ea248d

Please sign in to comment.