Module: NeetoCommonsBackend::Environments

Defined in:
lib/neeto_commons_backend/environments/test.rb,
lib/neeto_commons_backend/environments/heroku.rb,
lib/neeto_commons_backend/environments/staging.rb,
lib/neeto_commons_backend/environments/production.rb,
lib/neeto_commons_backend/environments/application.rb,
lib/neeto_commons_backend/environments/development.rb

Class Method Summary collapse

Class Method Details

.application(config, routes = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/neeto_commons_backend/environments/application.rb', line 6

def application(config, routes = nil)
  config.load_defaults 7.0
  config.serve_static_assets = true
  config.action_controller.raise_on_open_redirects = false
  config.active_storage.variant_processor = :mini_magick
  config.active_storage.service_urls_expire_in = 1.hour
  config.exceptions_app = routes unless routes.nil?

  config.active_record.encryption.primary_key = Rails.application.secrets.encryption[:primary_key]
  config.active_record.encryption.deterministic_key = Rails.application.secrets.encryption[:deterministic_key]
  config.active_record.encryption.key_derivation_salt = Rails.application.secrets.encryption[:key_derivation_salt]

  config.active_job.queue_adapter = :sidekiq
  config.active_job.default_queue_name = :default
  config.action_mailer.deliver_later_queue_name = :default
  config.active_storage.queues.analysis = :low
  config.active_storage.queues.purge = :low
  config.action_mailbox.queues.routing = :default
  config.action_mailbox.queues.incineration = :low

  NeetoCommonsBackend::Initializers.cache_store(config)
  config.generators do |generator|
    generator.orm :active_record, primary_key_type: :uuid
  end
end

.development(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/neeto_commons_backend/environments/development.rb', line 6

def development(config)
  config.cache_classes = false
  config.eager_load = false
  config.consider_all_requests_local = true
  config.active_storage.service = :local

  url_options = {
    host: "http://app.#{ENV["LOCALHOST_DOMAIN"]}",
    port: Rails.application.secrets.server_port
  }
  Rails.application.routes.default_url_options = url_options
  config.action_mailer.default_url_options = url_options
  config.action_mailer.delivery_method = :letter_opener
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.perform_caching = false
  config.active_support.deprecation = :log
  config.active_support.disallowed_deprecation = :raise
  config.active_support.disallowed_deprecation_warnings = []
  config.active_record.migration_error = :page_load
  config.active_record.verbose_query_logs = true
  config.assets.quiet = true
  config.server_timing = true
  config.i18n.raise_on_missing_translations = true
  config.webpacker.check_yarn_integrity = true
  config.hosts << /\A[*a-zA-Z0-9\-_]+\.*.*\z|\A*.*\z/
  if Rails.root.join("tmp/caching-dev.txt").exist?
    config.action_controller.perform_caching = true
    config.action_controller.enable_fragment_cache_logging = true
    config.cache_store = :memory_store
    config.public_file_server.headers = {
      "Cache-Control" => "public, max-age=#{2.days.to_i}"
    }
  else
    config.action_controller.perform_caching = false
    config.cache_store = :null_store
  end
end

.heroku(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/neeto_commons_backend/environments/heroku.rb', line 6

def heroku(config)
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local = false
  config.action_mailer.delivery_method = :letter_opener_web
  config.action_mailer.perform_deliveries = true
  config.action_mailer.perform_caching = false
  config.action_controller.perform_caching = true
  config.action_controller.forgery_protection_origin_check = false
  config.public_file_server.enabled = true
  config.assets.js_compressor = Uglifier.new(harmony: true)
  config.assets.compile = false
  config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
  config.log_level = :debug
  config.log_tags = [:request_id]
  config.log_formatter = ::Logger::Formatter.new
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.active_record.dump_schema_after_migration = false
  if Rails.application.secrets.asset_host.present?
    config.action_controller.asset_host = Rails.application.secrets.asset_host
  end
  if Rails.application.secrets.web_socket_server_url.present?
    config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
  end
  config.action_cable.disable_request_forgery_protection = true
end

.production(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/neeto_commons_backend/environments/production.rb', line 6

def production(config)
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local = false
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_controller.perform_caching = true
  config.assets.js_compressor = Uglifier.new(harmony: true)
  config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
  config.assets.compile = false
  if Rails.application.secrets.asset_host.present?
    config.action_controller.asset_host = Rails.application.secrets.asset_host
  end

  config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
  config.force_ssl = true
  config.log_level = Rails.application.secrets.log_level
  config.log_tags = [:request_id]
  config.action_mailer.perform_caching = false
  config.i18n.fallbacks = true
  config.active_support.report_deprecations = false
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
  config.action_controller.forgery_protection_origin_check = false

  config.action_cable.disable_request_forgery_protection = true
  if Rails.application.secrets.web_socket_server_url.present?
    config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
    config.action_cable.url = Rails.application.secrets.web_socket_server_url
  end

  config.public_file_server.enabled = true
  config.public_file_server.headers = {
    "Access-Control-Allow-Origin" => "*",
    "Cache-Control" => "public, max-age=31536000"
  }
end

.staging(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/neeto_commons_backend/environments/staging.rb', line 6

def staging(config)
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local = false
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_controller.perform_caching = true
  config.assets.js_compressor = Uglifier.new(harmony: true)
  config.assets.compile = false
  config.assets.digest = true
  config.force_ssl = true
  config.log_level = :debug
  config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
  config.log_tags = [:request_id]
  config.i18n.fallbacks = true
  config.active_support.report_deprecations = false
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
  config.action_controller.forgery_protection_origin_check = false
  if Rails.application.secrets.asset_host.present?
    config.action_controller.asset_host = Rails.application.secrets.asset_host
  end

  config.action_cable.disable_request_forgery_protection = true
  if Rails.application.secrets.web_socket_server_url.present?
    config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
    config.action_cable.url = Rails.application.secrets.web_socket_server_url
  end

  config.public_file_server.enabled = true
  config.public_file_server.headers = {
    "Access-Control-Allow-Origin" => "*",
    "Cache-Control" => "public, max-age=31536000"
  }
end

.test(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/neeto_commons_backend/environments/test.rb', line 6

def test(config)
  config.consider_all_requests_local = true
  config.cache_classes = true
  config.cache_store = :memory_store
  config.eager_load = false
  config.action_controller.perform_caching = false
  config.action_mailer.perform_caching = false
  config.action_mailer.delivery_method = :test
  config.action_mailer.perform_deliveries = true
  config.public_file_server.enabled = true
  config.public_file_server.headers = {
    "Cache-Control" => "public, max-age=#{1.hour.to_i}"
  }
  config.action_dispatch.show_exceptions = false
  config.action_controller.allow_forgery_protection = false
  config.active_storage.service = :test
  config.active_support.deprecation = :stderr
  config.active_support.disallowed_deprecation = :raise
  config.active_support.disallowed_deprecation_warnings = []
  config.i18n.raise_on_missing_translations = true
end