Commit 6abb2c3c authored by Sophie Daringer's avatar Sophie Daringer
Browse files

Setup stand alone api

parent a67d3d93
......@@ -43,3 +43,5 @@ end
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem "rack-cors", "~> 1.1"
gem "fast_jsonapi", "~> 1.5"
......@@ -83,6 +83,8 @@ GEM
crass (1.0.6)
diff-lcs (1.3)
erubi (1.9.0)
fast_jsonapi (1.5)
activesupport (>= 4.2)
ffi (1.12.2)
ffi (1.12.2-x64-mingw32)
globalid (0.4.2)
......@@ -252,6 +254,7 @@ DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
fast_jsonapi (~> 1.5)
jbuilder (~> 2.7)
listen (>= 3.0.5, < 3.2)
mdl_form!
......
class Api::V1::BaseController < ActionController::API
end
\ No newline at end of file
class Api::V1::UsersController < Api::V1::BaseController
def index
users = User.all
render json: UserSerializer.new(users).serialized_json
end
def show
user = User.find(params[:id])
render json: UserSerializer.new(user).serialized_json
end
end
\ No newline at end of file
class UserSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :email
end
......@@ -9,4 +9,10 @@ Rails.application.routes.draw do
get 'static/help'
get 'static/privacy'
root to: 'static#home'
namespace :api do
namespace :v1 do
resources :users, only: [:index, :create, :show, :update, :destroy]
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment