1- require_relative "boot"
2-
3- require "rails"
4- # Pick the frameworks you want:
5- require "active_model/railtie"
6- require "active_job/railtie"
7- require "active_record/railtie"
8- require "active_storage/engine"
9- require "action_controller/railtie"
10- require "action_mailer/railtie"
11- require "action_mailbox/engine"
12- require "action_text/engine"
13- require "action_view/railtie"
14- require "action_cable/engine"
15- # require "rails/test_unit/railtie"
16-
17- # Require the gems listed in Gemfile, including any gems
18- # you've limited to :test, :development, or :production.
19- Bundler . require ( *Rails . groups )
20-
21- module ProstaffApi
22- class Application < Rails ::Application
23- # Initialize configuration defaults for originally generated Rails version.
24- config . load_defaults 7.1
25-
26- # Please, add to the `ignore` list any other `lib` subdirectories that do
27- # not contain `.rb` files, or that should not be reloaded or eager loaded.
28- # Common ones are `templates`, `generators`, or `middleware`.
29- config . autoload_lib ( ignore : %w( assets tasks ) )
30-
31- # Configuration for the application, engines, and railties goes here.
32- #
33- # These settings can be overridden in specific environments using the files
34- # in config/environments/, which are processed later.
35- #
36- # config.time_zone = "Central Time (US & Canada)"
37- # config.eager_load_paths << Rails.root.join("extras")
38-
39- # Only loads a smaller set of middleware suitable for API only apps.
40- # Middleware like session, flash, cookies can be added back manually.
41- # Skip views, helpers and assets when generating a new resource.
42- config . api_only = true
43-
44- # Load modules directory
45- config . autoload_paths += %W( #{ config . root } /app/modules)
46- config . eager_load_paths += %W( #{ config . root } /app/modules)
47-
48- # CORS configuration
49- config . middleware . insert_before 0 , Rack ::Cors do
50- allow do
51- origins ENV . fetch ( 'CORS_ORIGINS' , 'http://localhost:5173' ) . split ( ',' )
52-
53- resource '*' ,
54- headers : :any ,
55- methods : [ :get , :post , :put , :patch , :delete , :options , :head ] ,
56- credentials : true ,
57- max_age : 86400
58- end
59- end
60-
61- # Rack Attack for rate limiting
62- config . middleware . use Rack ::Attack
63-
64- # Time zone
65- config . time_zone = 'UTC'
66-
67- # Generator configuration
68- config . generators do |g |
69- g . test_framework :rspec
70- g . factory_bot_dir 'spec/factories'
71- g . skip_routes true
72- g . helper false
73- g . assets false
74- g . view_specs false
75- g . helper_specs false
76- g . routing_specs false
77- g . controller_specs false
78- g . request_specs true
79- end
80- end
81- end
1+ # frozen_string_literal: true
2+
3+ require_relative 'boot'
4+
5+ require 'rails'
6+ # Pick the frameworks you want:
7+ require 'active_model/railtie'
8+ require 'active_job/railtie'
9+ require 'active_record/railtie'
10+ require 'active_storage/engine'
11+ require 'action_controller/railtie'
12+ require 'action_mailer/railtie'
13+ require 'action_mailbox/engine'
14+ require 'action_text/engine'
15+ require 'action_view/railtie'
16+ require 'action_cable/engine'
17+ # require "rails/test_unit/railtie"
18+
19+ # Require the gems listed in Gemfile, including any gems
20+ # you've limited to :test, :development, or :production.
21+ Bundler . require ( *Rails . groups )
22+
23+ module ProstaffApi
24+ class Application < Rails ::Application
25+ # Initialize configuration defaults for originally generated Rails version.
26+ config . load_defaults 7.1
27+
28+ # Please, add to the `ignore` list any other `lib` subdirectories that do
29+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
30+ # Common ones are `templates`, `generators`, or `middleware`.
31+ config . autoload_lib ( ignore : %w[ assets tasks ] )
32+
33+ # Configuration for the application, engines, and railties goes here.
34+ #
35+ # These settings can be overridden in specific environments using the files
36+ # in config/environments/, which are processed later.
37+ #
38+ # config.time_zone = "Central Time (US & Canada)"
39+ # config.eager_load_paths << Rails.root.join("extras")
40+
41+ # Only loads a smaller set of middleware suitable for API only apps.
42+ # Middleware like session, flash, cookies can be added back manually.
43+ # Skip views, helpers and assets when generating a new resource.
44+ config . api_only = true
45+
46+ # Load modules directory
47+ config . autoload_paths += %W[ #{ config . root } /app/modules]
48+ config . eager_load_paths += %W[ #{ config . root } /app/modules]
49+
50+ # CORS configuration
51+ config . middleware . insert_before 0 , Rack ::Cors do
52+ allow do
53+ origins ENV . fetch ( 'CORS_ORIGINS' , 'http://localhost:5173' ) . split ( ',' )
54+
55+ resource '*' ,
56+ headers : :any ,
57+ methods : %i[ get post put patch delete options head ] ,
58+ credentials : true ,
59+ max_age : 86_400
60+ end
61+ end
62+
63+ # Rack Attack for rate limiting
64+ config . middleware . use Rack ::Attack
65+
66+ # Time zone
67+ config . time_zone = 'UTC'
68+
69+ # Generator configuration
70+ config . generators do |g |
71+ g . test_framework :rspec
72+ g . factory_bot_dir 'spec/factories'
73+ g . skip_routes true
74+ g . helper false
75+ g . assets false
76+ g . view_specs false
77+ g . helper_specs false
78+ g . routing_specs false
79+ g . controller_specs false
80+ g . request_specs true
81+ end
82+ end
83+ end
0 commit comments