Skip to content

Commit 30c39fa

Browse files
committed
Added placeholder for API
1 parent e85b564 commit 30c39fa

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

app/api/.keep

Whitespace-only changes.

config/initializers/inflections.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ActiveSupport::Inflector.inflections do |inflect|
2+
inflect.acronym 'RESTful'
3+
inflect.acronym 'API'
4+
end

config/routes.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,31 @@
44
get '/.json', to: proc { [444, {}, ['']] }
55
get '/teams/.json', to: proc { [444, {}, ['']] }
66

7-
87
if Rails.env.development?
98
mount MailPreview => 'mail_view'
109
end
1110

12-
#TODO: REMOVE
11+
namespace :api, path: '/', constraints: { subdomain: 'api' } do
12+
end
13+
14+
# TODO: REMOVE
1315
match 'protips/update', via: %w(get put)
1416
match 'protip/update' , via: %w(get put)
17+
1518
get 'welcome' => 'home#index', as: :welcome
1619

1720
root to: 'protips#index'
1821

1922
get '/p/dpvbbg', controller: :protips, action: :show, id: 'devsal'
20-
get '/gh' , controller: :protips, action: :show, utm_campaign: 'github_orgs_badges' , utm_source:'github'
23+
get '/gh' , controller: :protips, action: :show, utm_campaign: 'github_orgs_badges' , utm_source: 'github'
2124

2225
get '/jobs(/:location(/:skill))' => 'opportunities#index', as: :jobs
2326
get '/jobs-map' => 'opportunities#map', as: :jobs_map
2427

25-
resources :protips, :path => '/p' do
28+
resources :protips, path: '/p' do
2629
collection do
2730
get 'u/:username' => 'protips#user', as: :user
28-
get ':id/:slug' => 'protips#show', as: :slug, :constraints => {:slug => /(?!.*?edit).*/}
31+
get ':id/:slug' => 'protips#show', as: :slug, :constraints => { slug: /(?!.*?edit).*/ }
2932
get 'random'
3033
get 'search' => 'protips#search', as: :search
3134
post 'search' => 'protips#search'
@@ -44,6 +47,7 @@
4447
get 'liked'
4548
post 'preview'
4649
end
50+
4751
member do
4852
post 'upvote'
4953
post 'report_inappropriate'
@@ -53,16 +57,17 @@
5357
topic_regex = /[A-Za-z0-9#\$\+\-_\.(%23)(%24)(%2B)]+/
5458
post 'delete_tag/:topic' => 'protips#delete_tag', as: :delete_tag, :topic => topic_regex
5559
end
56-
resources :comments, :constraints => {id: /\d+/} do
60+
resources :comments, constraints: { id: /\d+/ } do
5761
member { post 'like' }
5862
end
5963
end
6064

61-
resources :networks, :path => '/n', :constraints => {:slug => /[\dA-Z\-]/i} do
65+
resources :networks, path: '/n', constraints: { slug: /[\dA-Z\-]/i } do
6266
collection do
6367
get 'featured' => 'networks#featured', as: :featured
6468
get '/u/:username' => 'networks#user', as: :user
6569
end
70+
6671
member do
6772
get '/t/(/*tags)' => 'networks#tag', as: :tagged
6873
get '/members' => 'networks#members', as: :members
@@ -108,7 +113,7 @@
108113
get '/alerts' => 'alerts#create', :via => :post
109114
get '/alerts' => 'alerts#index', :via => :get
110115

111-
#get '/payment' => 'accounts#new', as: :payment
116+
# get '/payment' => 'accounts#new', as: :payment
112117

113118
post '/users/:username/follow' => 'follows#create', as: :follow_user, :type => :user
114119

@@ -121,7 +126,7 @@
121126
get 'accept'
122127
post 'record-exit' => 'teams#record_exit', as: :record_exit
123128
get 'visitors'
124-
#TODO following and unfollowing should use different HTTP verbs (:post, :delete)
129+
# TODO following and unfollowing should use different HTTP verbs (:post, :delete)
125130
# Fix views and specs when changing this.
126131
post 'follow'
127132
post 'join'
@@ -151,7 +156,7 @@
151156
get '/leaderboard' => 'teams#leaderboard', as: :leaderboard
152157
get '/employers' => 'teams#upgrade', as: :employers
153158

154-
['github', 'twitter', 'forrst', 'dribbble', 'linkedin', 'codeplex', 'bitbucket', 'stackoverflow'].each do |provider|
159+
%w(github twitter forrst dribbble linkedin codeplex bitbucket stackoverflow).each do |provider|
155160
post "/#{provider}/unlink" => 'users#unlink_provider', :provider => provider, as: "unlink_#{provider}".to_sym
156161
get "/#{provider}/:username" => 'users#show', :provider => provider
157162
end
@@ -179,7 +184,6 @@
179184
get '/nextaccomplishment' => 'highlights#random', as: :random_accomplishment
180185
get '/add-skill' => 'skills#create', as: :add_skill, :via => :post
181186

182-
183187
get '/blog' => 'blog_posts#index', as: :blog
184188
get '/blog/:id' => 'blog_posts#show', as: :blog_post
185189
get '/articles.atom' => 'blog_posts#index', as: :atom, :format => :atom
@@ -192,9 +196,9 @@
192196

193197
get '/providers/:provider/:username' => 'provider_user_lookups#show'
194198

195-
match '/404' => 'errors#not_found', via: [ :get, :post, :patch, :delete ]
196-
match "/422" => "errors#unacceptable", via: [ :get, :post, :patch, :delete ]
197-
match "/500" => "errors#internal_error", via: [ :get, :post, :patch, :delete ]
199+
match '/404' => 'errors#not_found', via: [:get, :post, :patch, :delete]
200+
match '/422' => 'errors#unacceptable', via: [:get, :post, :patch, :delete]
201+
match '/500' => 'errors#internal_error', via: [:get, :post, :patch, :delete]
198202

199203
constraints ->(params, _) { params[:username] != 'admin' } do
200204
get '/:username' => 'users#show', as: :badge
@@ -210,17 +214,16 @@
210214
end
211215

212216
require_admin = ->(_, req) { User.where(id: req.session[:current_user], admin: true).exists? }
213-
scope :admin, as: :admin, :path => '/admin', :constraints => require_admin do
217+
scope :admin, as: :admin, path: '/admin', constraints: require_admin do
214218
get '/' => 'admin#index', as: :root
215219
get '/teams' => 'admin#teams', as: :teams
216220
get '/teams/sections/:num_sections' => 'admin#sections_teams', as: :sections_teams
217221
get '/teams/section/:section' => 'admin#section_teams', as: :section_teams
218222
mount Sidekiq::Web => '/sidekiq'
219223
end
220-
#TODO: namespace inside admin
224+
# TODO: namespace inside admin
221225
get '/comments' => 'comments#index', as: :latest_comments
222226

223-
224227
end
225228

226229
# == Route Map

0 commit comments

Comments
 (0)