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
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
8181end
0 commit comments