summaryrefslogtreecommitdiffhomepage
path: root/rails-backend/config/application.rb
blob: 6e54549e66f75829d4888b8841d023bf7d9ca646 (plain)
1
2
3
4
5
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require_relative "boot"

require "rails/all"
require 'tomlib'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module GameHolster
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 7.1

    # Please, add to the `ignore` list any other `lib` subdirectories that do
    # not contain `.rb` files, or that should not be reloaded or eager loaded.
    # Common ones are `templates`, `generators`, or `middleware`, for example.
    config.autoload_lib(ignore: %w(assets tasks))

    # Configuration for the application, engines, and railties goes here.
    #
    # These settings can be overridden in specific environments using the files
    # in config/environments, which are processed later.
    #
    # config.time_zone = "Central Time (US & Canada)"
    # config.eager_load_paths << Rails.root.join("extras")

    # Only loads a smaller set of middleware suitable for API only apps.
    # Middleware like session, flash, cookies can be added back manually.
    # Skip views, helpers and assets when generating a new resource.
    config.api_only = true

    config.middleware.use ActionDispatch::Cookies
    config.middleware.use ActionDispatch::Session::CookieStore

    config.active_storage.content_types_allowed_inline << "text/html"

    #localhost:5173
    #config.session_store :cookie_store, key: 'session', domain: :all, tld_length: 5

    #config.before_configuration do
    #  env_file = File.join(Rails.root, 'config', 'local_env.yml')
    #  if File.exist?(env_file)
    #    YAML.load(File.open(env_file)).each do |key, value|
    #      ENV[key.to_s] = value
    #    end
    #  end
    #end
    config.before_configuration do
      env_file = File.join(Rails.root, 'config', 'env.toml')
      if File.exist?(env_file)
        env = Tomlib.load(File.read(env_file))
        env['default'].each do |key, value|
          ENV[key] = value
        end
        if Rails.env.production?
          env['production'].each do |key, value|
            ENV[key] = value
          end
        elsif Rails.env.development?
          env['development'].each do |key, value|
            ENV[key] = value
          end
        end
      end
    end
  end
end