Skip to content

Commit

Permalink
API v1 user endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Oct 13, 2018
1 parent fd96b6c commit 110c7cc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gem 'daemons'
gem 'doorkeeper'
gem 'doorkeeper-i18n'
gem 'rack-cors', require: 'rack/cors'
gem 'active_model_serializers', '~> 0.10.0'
gem 'twitter-bootstrap-rails', '~> 2.2.8'
gem 'simple-navigation', '~> 3.14.0' # 3.x for simple_navigation_bootstrap
gem 'simple-navigation-bootstrap'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ GEM
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.10.7)
actionpack (>= 4.1, < 6)
activemodel (>= 4.1, < 6)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (4.2.10)
activesupport (= 4.2.10)
globalid (>= 0.3.0)
Expand Down Expand Up @@ -115,6 +120,8 @@ GEM
capybara-webkit (1.14.0)
capybara (>= 2.3.0, < 2.14.0)
json
case_transform (0.2)
activesupport
chronic (0.10.2)
coderay (1.1.2)
coffee-rails (4.2.2)
Expand Down Expand Up @@ -210,6 +217,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
jsonapi-renderer (0.2.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
Expand Down Expand Up @@ -488,6 +496,7 @@ PLATFORMS
ruby

DEPENDENCIES
active_model_serializers (~> 0.10.0)
acts_as_tree
acts_as_versioned!
attribute_normalizer
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v1/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class Api::V1::BaseController < ApplicationController
protect_from_forgery with: :null_session

before_action :skip_session
before_action :authenticate

rescue_from ActiveRecord::RecordNotFound, with: :not_found_handler
rescue_from ActiveRecord::RecordNotSaved, with: :not_acceptable_handler
rescue_from ActiveRecord::RecordInvalid, with: :not_acceptable_handler
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Api::V1::UsersController < Api::V1::BaseController

def show
render json: current_user
end

end
3 changes: 3 additions & 0 deletions app/serializers/user_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class UserSerializer < ActiveModel::Serializer
attributes :id, :name, :email, :locale
end
1 change: 1 addition & 0 deletions config/initializers/active_model_serializers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ActiveModelSerializers.config.adapter = :json
8 changes: 8 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@
end
end

############## API

namespace :api do
namespace :v1 do
resource :user, only: [:show]
end
end

############## Feedback

resource :feedback, only: [:new, :create], controller: 'feedback'
Expand Down

0 comments on commit 110c7cc

Please sign in to comment.