Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AC Web#11 API design Q1 #118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ gem 'carrierwave_backgrounder'
# soft delete
gem 'paranoia'

#language switch
gem 'rails-i18n'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
group :staging, :production do
Expand All @@ -60,7 +63,7 @@ group :development do
# unicorn
gem 'capistrano3-unicorn'
# slack
gem 'slackistrano', require: false
gem 'slackistrano'#, require: false

gem 'annotate'
gem 'xray-rails'
Expand Down
91 changes: 49 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.3)
CFPropertyList (2.3.4)
actionmailer (4.2.7.1)
actionpack (= 4.2.7.1)
actionview (= 4.2.7.1)
Expand Down Expand Up @@ -44,28 +44,31 @@ GEM
activerecord (>= 4.0)
acts_as_list (0.8.2)
activerecord (>= 3.0)
addressable (2.4.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
airbrussh (1.1.1)
sshkit (>= 1.6.1, != 1.7.0)
annotate (2.7.1)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
arel (6.0.3)
asset_sync (1.2.1)
asset_sync (1.3.0)
activemodel
fog (>= 1.8.0)
mime-types
unf
ast (2.3.0)
aws-sdk (2.6.12)
aws-sdk-resources (= 2.6.12)
aws-sdk-core (2.6.12)
aws-sdk (2.6.34)
aws-sdk-resources (= 2.6.34)
aws-sdk-core (2.6.34)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.6.12)
aws-sdk-core (= 2.6.12)
aws-sdk-resources (2.6.34)
aws-sdk-core (= 2.6.34)
aws-sdk-v1 (1.66.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
aws-sigv4 (1.0.0)
bcrypt (3.1.11)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
Expand All @@ -83,13 +86,13 @@ GEM
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-harrow (0.5.3)
capistrano-rails (1.1.8)
capistrano-rails (1.2.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.4)
capistrano-rbenv (2.1.0)
capistrano (~> 3.1)
sshkit (~> 1.3)
capistrano-sidekiq (0.5.4)
capistrano-sidekiq (0.10.0)
capistrano
sidekiq (>= 3.4)
capistrano3-unicorn (0.2.1)
Expand Down Expand Up @@ -125,9 +128,9 @@ GEM
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
coffee-script-source (1.11.1)
concurrent-ruby (1.0.2)
connection_pool (2.2.0)
connection_pool (2.2.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crummy (1.8.0)
Expand Down Expand Up @@ -193,7 +196,7 @@ GEM
fog-atmos (0.1.0)
fog-core
fog-xml
fog-aws (0.12.0)
fog-aws (0.13.0)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
Expand Down Expand Up @@ -225,20 +228,20 @@ GEM
fog-json (1.0.2)
fog-core (~> 1.0)
multi_json (~> 1.10)
fog-local (0.3.0)
fog-local (0.3.1)
fog-core (~> 1.27)
fog-openstack (0.1.15)
fog-openstack (0.1.18)
fog-core (>= 1.40)
fog-json (>= 1.0)
ipaddress (>= 0.8)
fog-powerdns (0.1.1)
fog-core (~> 1.27)
fog-json (~> 1.0)
fog-xml (~> 0.1)
fog-profitbricks (2.0.1)
fog-profitbricks (3.0.0)
fog-core (~> 1.42)
fog-json (~> 1.0)
fog-rackspace (0.1.1)
fog-rackspace (0.1.2)
fog-core (>= 1.35)
fog-json (>= 1.0)
fog-xml (>= 0.1)
Expand Down Expand Up @@ -272,7 +275,7 @@ GEM
fog-voxel (0.1.0)
fog-core
fog-xml
fog-vsphere (1.4.0)
fog-vsphere (1.5.2)
fog-core
rbvmomi (~> 1.9)
fog-xenserver (0.2.3)
Expand All @@ -284,7 +287,7 @@ GEM
formatador (0.2.5)
globalid (0.3.7)
activesupport (>= 4.1.0)
hashdiff (0.3.0)
hashdiff (0.3.1)
hashie (3.4.6)
hike (1.2.3)
hitimes (1.2.4)
Expand All @@ -293,15 +296,15 @@ GEM
ice_cube (0.14.0)
inflecto (0.0.2)
ipaddress (0.8.3)
jbuilder (2.6.0)
jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jmespath (1.3.1)
jquery-rails (4.2.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.5)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (1.8.3)
jwt (1.5.6)
Expand All @@ -319,17 +322,17 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_magick (4.5.1)
mini_magick (4.6.0)
mini_portile2 (2.1.0)
minitest (5.9.1)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.5.5)
multi_xml (0.6.0)
multipart-post (2.0.0)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
newrelic_rpm (3.17.0.325)
newrelic_rpm (3.17.1.326)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.2.0)
Expand All @@ -355,18 +358,19 @@ GEM
oauth2 (~> 1.0)
omniauth (~> 1.2)
orm_adapter (0.5.0)
paper_trail (5.2.2)
activerecord (>= 3.0, < 6.0)
paper_trail (6.0.1)
activerecord (>= 4.0, < 5.2)
request_store (~> 1.1)
paranoia (2.2.0)
activerecord (>= 4.0, < 5.1)
parser (2.3.1.4)
parser (2.3.3.1)
ast (~> 2.2)
pg (0.19.0)
polyamorous (1.3.1)
activerecord (>= 3.0)
powerpack (0.1.1)
rack (1.6.4)
public_suffix (2.0.4)
rack (1.6.5)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
Expand All @@ -390,6 +394,9 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-i18n (4.0.9)
i18n (~> 0.7)
railties (~> 4.0)
railties (4.2.7.1)
actionpack (= 4.2.7.1)
activesupport (= 4.2.7.1)
Expand All @@ -409,9 +416,8 @@ GEM
json (>= 1.8)
nokogiri (~> 1.5)
trollop (~> 2.1)
rdoc (4.2.2)
json (~> 1.4)
redis (3.3.1)
rdoc (4.3.0)
redis (3.3.2)
redis-objects (1.2.1)
redis (>= 3.0.2)
request_store (1.3.1)
Expand Down Expand Up @@ -444,7 +450,7 @@ GEM
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubocop (0.44.1)
rubocop (0.46.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
Expand All @@ -464,7 +470,7 @@ GEM
select2-rails (3.5.10)
thor (~> 0.14)
settingslogic (2.0.9)
sidekiq (4.2.3)
sidekiq (4.2.7)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
Expand Down Expand Up @@ -499,31 +505,31 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sshkit (1.11.3)
sshkit (1.11.4)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.7.7)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.19.1)
thor (0.19.4)
thread_safe (0.3.5)
tilt (1.4.1)
timecop (0.8.1)
timers (4.1.1)
timers (4.1.2)
hitimes
trollop (2.1.2)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.2)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicode-display_width (1.1.1)
unicorn (5.1.0)
unicorn (5.2.0)
kgio (~> 2.6)
raindrops (~> 0.7)
warden (1.2.6)
Expand All @@ -533,7 +539,7 @@ GEM
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (2.1.0)
webmock (2.3.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand Down Expand Up @@ -587,6 +593,7 @@ DEPENDENCIES
paranoia
pg
rails (= 4.2.7.1)
rails-i18n
ransack
redis
redis-objects
Expand Down Expand Up @@ -617,4 +624,4 @@ DEPENDENCIES
xray-rails

BUNDLED WITH
1.12.5
1.13.1
38 changes: 38 additions & 0 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class Api::BaseController < ApplicationController
before_action :set_default_format
before_action :enabled_cors
skip_before_action :verify_authenticity_token


private

# def authenticate_user_from_token!

# if params[:auth_token].present?
# user = User.find_by_authentication_token(params[:auth_token])

# sign_in(user, store: false) if user

# end

# end

# def add_after_action
# response.headers['Access-Control-Allow-Origin'] = '*'
# response.headers['Access-Control-Allow-Methods'] = 'POST, PUT, GET, OPTIONS'
# response.headers['Access-Control-Allow-Headers'] = 'Origin, X-Reuqested-With, Content-Type, Accept'
# end

def set_default_format
request.format = 'json'
end

def enabled_cors
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Atmosphere-tracking-id, X-Atmosphere-Framework, X-Cache-Date, Content-Type, X-Atmosphere-Transport, X-Remote, api_key, auth_token, *'
headers['Access-Control-Request-Method'] = 'GET, POST, PUT, DELETE'
headers['Access-Control-Request-Headers'] = 'Origin, X-Atmosphere-tracking-id, X-Atmosphere-Framework, X-Cache-Date, Content-Type, X-Atmosphere-Transport, X-Remote, api_key, *'
end

end
Loading