Rails.application.routes.draw do # Signed-in users only, with the upload rules checked before any bytes are sent # (overrides Active Storage's open endpoint at the same path). post "rails/active_storage/direct_uploads", to: "direct_uploads#create" resource :session, only: %i[new create destroy] do get :two_factor post :two_factor, action: :verify_two_factor end resource :two_factor, path: "profile/two_factor", only: %i[new create destroy] do post :recovery_codes end resources :sign_in_links, path: "session/link", param: :token, only: %i[new create show] do post :consume, on: :member end # Single sign-on: POST /auth/oidc (handled by OmniAuth) comes back here. match "auth/:provider/callback", to: "sso#callback", via: %i[get post], as: :sso_callback get "auth/failure", to: "sso#failure" delete "profile/sso", to: "sso#destroy", as: :sso_link delete "profile/sessions", to: "profiles#sign_out_others", as: :other_sessions resources :passwords, param: :token, only: %i[new create edit update] resource :setup, only: %i[new create], controller: "setup" resource :profile, only: %i[edit update] resource :push_subscription, path: "profile/push", only: %i[create destroy] do post :test end # Home-screen shortcuts: the form for your aircraft, or a choice of aircraft. get "go/log-flight", to: "shortcuts#log_flight", as: :log_flight_shortcut get "go/report-squawk", to: "shortcuts#report_squawk", as: :report_squawk_shortcut resources :api_tokens, path: "profile/api_tokens", only: %i[create destroy] resources :certificates, path: "profile/certificates", controller: "user_certificates", only: %i[create update destroy] resource :air_trail_connection, path: "profile/airtrail", only: %i[show create update destroy] do post :test post :sync post :map_airport end resources :aircraft_imports, path: "imports", only: %i[new create show] resources :aircraft do member do patch :hours, action: :update_hours end resources :components do member { post :reset_service } end resources :squawks, except: :show do member do get :resolution patch :resolve patch :reopen get :deferral patch :defer patch :undefer end end resources :notes, except: :show do post :preview, on: :collection end resources :flight_logs, only: %i[index new create show edit update destroy] do member do get :engine_data, action: :engine_data_series patch :engine_data, action: :attach_engine_data delete :engine_data, action: :remove_engine_data end end resource :air_trail_export, path: "airtrail_export", only: %i[new create] resource :airport_codes, only: %i[show update] resource :flight_import, only: %i[new create show] do post :confirm end resources :consumable_records, path: "consumables", except: :show resources :oil_analyses, path: "oil_analysis" do collection { post :import } end resources :logbook_imports, path: "logbook/import", only: %i[new create show] resource :logbook_print, path: "logbook/print", only: %i[new show] resources :logbook_entries do member { patch :verify } resource :signature, controller: "entry_signatures", only: %i[new create] resources :signing_invitations, only: %i[new create] end resources :documents do collection do get :bulk, action: :bulk_new, as: :new_bulk post :bulk, action: :bulk_create end end resources :document_collections, except: %i[index show] resources :inspections, only: :index resources :inspection_types, except: %i[index show] resource :standard_inspections, only: %i[new create] resources :inspection_records, except: %i[index show] resources :ad_alerts, path: "ads/new_ads", only: [] do member do post :track post :dismiss end collection do post :check patch :terms end end resources :airworthiness_directives, path: "ads", except: :show do collection { post :attach } end resources :ad_compliances, except: %i[index show] resource :ad_import, only: %i[new create show] do post :confirm end resources :major_records resource :loading_setup, path: "weight_balance/loading", only: %i[edit update] # before the records' :id routes resources :weight_balance_records, path: "weight_balance", except: :show resources :aircraft_roles, path: "access", only: %i[index create update destroy] resources :invitations, controller: "aircraft_invitations", only: %i[create destroy] resources :share_tokens, only: %i[create destroy] resource :export, controller: "aircraft_exports", only: :show resource :report, controller: "maintenance_reports", only: :show resource :records_package, path: "records", only: :show resources :record_versions, path: "history", only: :index do member { post :restore } end resources :events, only: :index end get "airports/search", to: "airports#search", as: :airport_search get "search", to: "searches#show", as: :search get "help", to: "help#show", as: :help get "help/records", to: "help#show", defaults: { page: "records" }, as: :records_help get "help/:page", to: "help#show", as: :help_page, constraints: { page: /[a-z-]+/ } # Public read-only share links (no login). # Invited signers (outside mechanics) sign one entry. get "sign/:token", to: "invited_signings#show", as: :invited_signing # Invitation codes (AccessInvitation): an account and roles on aircraft. get "join/:token", to: "joins#show", as: :join post "join/:token/accept", to: "joins#accept", as: :accept_join post "join/:token/account", to: "joins#account", as: :account_join post "sign/:token", to: "invited_signings#create" post "sign/:token/account", to: "invited_signings#account", as: :account_invited_signing # Calendar feed of what's coming due (secret link; calendar apps can't sign in). get "calendar/:token.ics", to: "calendar_feeds#show", as: :calendar_feed, constraints: { token: /[A-Za-z0-9]{32}/ }, format: false, defaults: { format: "ics" } resource :calendar_token, path: "profile/calendar", only: :create get "shared/:token", to: "shared#show", as: :shared get "shared/:token/report", to: "shared#report", as: :shared_report namespace :admin do resources :users, only: [] do member do patch :disable patch :enable patch :unlock patch :reset_two_factor end end get "about", to: "about#show" resource :settings, only: %i[edit update] resource :procedures, only: %i[show update] do get :draft post :adopt get "revisions/:id", action: :revision, as: :revision end resources :audits, only: %i[index new create show] resource :offsite_backup, only: %i[show update destroy] do get :connect get :callback post :backup_now post :restore_test end resources :logbook_templates, except: :show do collection { post :restore } end post "about/test_email", to: "about#test_email", as: :test_email post "about/test_reminder", to: "about#test_reminder", as: :test_reminder post "about/check_records", to: "about#check_records", as: :check_records resources :users, except: :show do resources :aircraft_roles, controller: "user_aircraft_roles", only: %i[create update destroy] end resources :roles, except: :show resources :invitations, only: %i[index new create destroy] resources :integrations do post :new_secret, on: :member end resources :component_types, except: :show resources :airports, except: :show do collection { post :refresh } end end # REST API (docs/api.md): bearer tokens, JSON. namespace :api, defaults: { format: :json } do namespace :v1 do get "me", to: "me#show" resources :aircraft, only: %i[index show] do member do get :components get :due get :inspections get :ads get :logbook_entries end resources :squawks, only: %i[index create] resources :draft_batches, only: %i[index create] end get "squawks", to: "squawks#lookup" resources :squawks, only: %i[show update] get "draft_batches", to: "draft_batches#lookup" resources :draft_batches, only: %i[show destroy] end end get "up" => "rails/health#show", as: :rails_health_check get "manifest" => "rails/pwa#manifest", as: :pwa_manifest get "offline" => "offline#show", as: :offline get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker root "aircraft#index" end