diff --git a/app/services/api.rb b/app/services/api.rb index 589cc0275..a06f328be 100644 --- a/app/services/api.rb +++ b/app/services/api.rb @@ -16,12 +16,14 @@ module Api attr_accessor :core_api_token_ttl attr_accessor :core_api_token_iss attr_accessor :azure_ad_apps + attr_accessor :core_api_v1_preview def initialize @core_api_sign_alg = 'HS256' @core_api_token_ttl = 30.minutes @core_api_token_iss = 'SciNote' @azure_ad_apps = {} + @core_api_v1_preview = false end end end diff --git a/config/initializers/api.rb b/config/initializers/api.rb index 4ab3e3898..cad116bbf 100644 --- a/config/initializers/api.rb +++ b/config/initializers/api.rb @@ -9,6 +9,8 @@ Api.configure do |config| config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS'] end + config.core_api_v1_preview = true if ENV['CORE_API_V1_PREVIEW'] + vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ } vars.each do |name, value| app_name = name.sub('_AZURE_AD_APP_ID', '') diff --git a/config/routes.rb b/config/routes.rb index ddca6879a..785cd4805 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -540,8 +540,10 @@ Rails.application.routes.draw do get 'health', to: 'api#health' get 'status', to: 'api#status' post 'auth/token', to: 'api#authenticate' - namespace :v1 do - resources :teams, only: %i(index show) do + if Api.configuration.core_api_v1_preview + namespace :v1 do + resources :teams, only: %i(index show) do + end end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 79e319489..1f74b4ae3 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,6 +5,9 @@ require 'database_cleaner' require 'devise' require_relative 'support/controller_macros' ENV['RAILS_ENV'] = 'test' + +ENV['CORE_API_V1_PREVIEW'] = 'true' + require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production?