API v1 user endpoint

This commit is contained in:
wvengen 2018-10-13 15:15:43 +02:00 committed by wvengen
parent fd96b6ccc1
commit 110c7cc3e9
7 changed files with 31 additions and 0 deletions

View File

@ -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'

View File

@ -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)
@ -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)
@ -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)
@ -488,6 +496,7 @@ PLATFORMS
ruby
DEPENDENCIES
active_model_serializers (~> 0.10.0)
acts_as_tree
acts_as_versioned!
attribute_normalizer

View File

@ -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

View File

@ -0,0 +1,7 @@
class Api::V1::UsersController < Api::V1::BaseController
def show
render json: current_user
end
end

View File

@ -0,0 +1,3 @@
class UserSerializer < ActiveModel::Serializer
attributes :id, :name, :email, :locale
end

View File

@ -0,0 +1 @@
ActiveModelSerializers.config.adapter = :json

View File

@ -241,6 +241,14 @@ Foodsoft::Application.routes.draw do
end
end
############## API
namespace :api do
namespace :v1 do
resource :user, only: [:show]
end
end
############## Feedback
resource :feedback, only: [:new, :create], controller: 'feedback'