From 87217c058276a63b3f803792b230cd64549e9d73 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Wed, 18 Feb 2026 11:14:35 +0000 Subject: [PATCH 1/2] feat: add built-in rails endpoint --- config/routes.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index c9c46204c2..d4db24d74e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,9 +4,12 @@ user_is_admin = ->(req) { User.find_by(id: req.session[:user])&.administrator? } root to: 'homes#show' - resource :health, only: [:show] resource :home, only: [:show] + # 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 + resource :phi_x, only: [:show] do scope module: :phi_x do resources :stocks From 87ee016420997293c4f21cf54864e5bc32238696 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Wed, 18 Feb 2026 11:21:11 +0000 Subject: [PATCH 2/2] refactor: order and group routes --- config/routes.rb | 52 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index d4db24d74e..9537b58216 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ 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 :home, only: [:show] @@ -10,18 +10,31 @@ 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 - resource :phi_x, only: [:show] do - scope module: :phi_x do - resources :stocks - resources :spiked_buffers - end - end - # 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`), @@ -144,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 @@ -347,8 +357,6 @@ end end - resources :searches - namespace :admin do resources :abilities, only: :index resources :custom_texts @@ -452,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. @@ -471,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 @@ -630,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 @@ -649,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'