Skip to content
Merged
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
55 changes: 31 additions & 24 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,39 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

user_is_admin = ->(req) { User.find_by(id: req.session[:user])&.administrator? }
# Home
root to: 'homes#show'
resource :health, only: [:show]
resource :home, only: [:show]

resource :phi_x, only: [:show] do
scope module: :phi_x do
resources :stocks
resources :spiked_buffers
end
end
# Health check endpoints
get 'health' => 'health#show', constraints: ->(req) { req.format == :json } # json with stats
get 'health' => 'rails/health#show', as: :rails_health_check # default Rails health check

# Error handling endpoints
get '/404', to: 'errors#not_found'
get '/500', to: 'errors#internal_server_error'
get '/503', to: 'errors#service_unavailable'

# Session authentication endpoints
match '/login' => 'sessions#login', :as => :login, :via => %i[get post]
match '/logout' => 'sessions#logout', :as => :logout, :via => %i[get post]
# this is for test only test/functional/authentication_controller_test.rb
# to be removed?
get 'authentication/open'
get 'authentication/restricted'

# Feature flags
user_is_admin = ->(req) { User.find_by(id: req.session[:user])&.administrator? }
mount Flipper::UI.app => '/flipper', :constraints => user_is_admin

# Search
resources :searches
resources :lab_searches

get 'advanced_search' => 'advanced_search#index'
post 'advanced_search/search' => 'advanced_search#search'

# API v1
mount Api::RootService.new => '/api/1' unless ENV['DISABLE_V1_API']

# @todo Update v2 resources exceptions to reflect resources (e.g., `, except: %i[update]` for `lot`),
Expand Down Expand Up @@ -141,9 +157,6 @@
end
end

match '/login' => 'sessions#login', :as => :login, :via => %i[get post]
match '/logout' => 'sessions#logout', :as => :logout, :via => %i[get post]

resources :plate_summaries, only: %i[index show] do
collection { get :search }
end
Expand Down Expand Up @@ -344,8 +357,6 @@
end
end

resources :searches

namespace :admin do
resources :abilities, only: :index
resources :custom_texts
Expand Down Expand Up @@ -449,12 +460,8 @@
end
end

resources :lab_searches
resources :events

get 'advanced_search' => 'advanced_search#index'
post 'advanced_search/search' => 'advanced_search#search'

resources :workflows, only: [] do
member do
# Yes, this is every bit as horrible as it looks.
Expand All @@ -468,6 +475,13 @@
collection { get :generate_manifest }
end

resource :phi_x, only: [:show] do
scope module: :phi_x do
resources :stocks
resources :spiked_buffers
end
end

resources :asset_audits

resources :qc_reports, except: %i[delete update] do
Expand Down Expand Up @@ -627,11 +641,6 @@

resources :location_reports, only: %i[index show create]

# this is for test only test/functional/authentication_controller_test.rb
# to be removed?
get 'authentication/open'
get 'authentication/restricted'

resources :messengers, only: :show

# We removed workflows, which broke study links. Some customers may have their own studies bookmarked
Expand All @@ -646,8 +655,6 @@
end
end

mount Flipper::UI.app => '/flipper', :constraints => user_is_admin

# Custom standalone route for bioscan control locations, allowing only
# the POST request, migrated from the Lighthouse pickings endpoint.
post 'bioscan_control_locations', to: 'bioscan_control_locations#create'
Expand Down
Loading