trailblazer-endpoint 0.0.3 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -0
  3. data/Appraisals +5 -0
  4. data/CHANGES.md +27 -0
  5. data/README.md +40 -5
  6. data/Rakefile +7 -1
  7. data/gemfiles/rails_app.gemfile +12 -0
  8. data/lib/trailblazer/endpoint.rb +50 -14
  9. data/lib/trailblazer/endpoint/adapter.rb +30 -121
  10. data/lib/trailblazer/endpoint/builder.rb +1 -1
  11. data/lib/trailblazer/endpoint/controller.rb +217 -1
  12. data/lib/trailblazer/endpoint/dsl.rb +8 -3
  13. data/lib/trailblazer/endpoint/options.rb +16 -69
  14. data/lib/trailblazer/endpoint/protocol.rb +7 -11
  15. data/lib/trailblazer/endpoint/protocol/cipher.rb +27 -0
  16. data/lib/trailblazer/endpoint/protocol/controller.rb +102 -0
  17. data/lib/trailblazer/endpoint/protocol/find_process_model.rb +15 -0
  18. data/lib/trailblazer/endpoint/version.rb +1 -1
  19. data/test/adapter/api_test.rb +6 -11
  20. data/test/adapter/web_test.rb +2 -5
  21. data/test/config_test.rb +25 -0
  22. data/test/docs/controller_test.rb +220 -73
  23. data/test/endpoint_test.rb +1 -1
  24. data/test/rails-app/.gitignore +8 -2
  25. data/test/rails-app/.ruby-version +1 -0
  26. data/test/rails-app/Gemfile +21 -9
  27. data/test/rails-app/Gemfile.lock +174 -118
  28. data/test/rails-app/app/concepts/app/api/v1/representer/errors.rb +16 -0
  29. data/test/rails-app/app/concepts/auth/jwt.rb +35 -0
  30. data/test/rails-app/app/concepts/auth/operation/authenticate.rb +32 -0
  31. data/test/rails-app/app/concepts/auth/operation/policy.rb +9 -0
  32. data/test/rails-app/app/concepts/song/cell/create.rb +4 -0
  33. data/test/rails-app/app/concepts/song/cell/new.rb +4 -0
  34. data/test/rails-app/app/concepts/song/operation/create.rb +17 -0
  35. data/test/rails-app/app/concepts/song/operation/show.rb +10 -0
  36. data/test/rails-app/app/concepts/song/representer.rb +5 -0
  37. data/test/rails-app/app/concepts/song/view/create.erb +1 -0
  38. data/test/rails-app/app/concepts/song/view/new.erb +1 -0
  39. data/test/rails-app/app/controllers/api/v1/songs_controller.rb +41 -0
  40. data/test/rails-app/app/controllers/application_controller.rb +8 -1
  41. data/test/rails-app/app/controllers/application_controller/api.rb +107 -0
  42. data/test/rails-app/app/controllers/application_controller/web.rb +46 -0
  43. data/test/rails-app/app/controllers/auth_controller.rb +44 -0
  44. data/test/rails-app/app/controllers/home_controller.rb +5 -0
  45. data/test/rails-app/app/controllers/songs_controller.rb +254 -13
  46. data/test/rails-app/app/models/song.rb +6 -0
  47. data/test/rails-app/app/models/user.rb +7 -0
  48. data/test/rails-app/bin/bundle +114 -0
  49. data/test/rails-app/bin/rails +4 -0
  50. data/test/rails-app/bin/rake +4 -0
  51. data/test/rails-app/bin/setup +33 -0
  52. data/test/rails-app/config/application.rb +26 -3
  53. data/test/rails-app/config/credentials.yml.enc +1 -0
  54. data/test/rails-app/config/database.yml +2 -2
  55. data/test/rails-app/config/environments/development.rb +7 -17
  56. data/test/rails-app/config/environments/production.rb +28 -23
  57. data/test/rails-app/config/environments/test.rb +10 -12
  58. data/test/rails-app/config/initializers/application_controller_renderer.rb +6 -4
  59. data/test/rails-app/config/initializers/cors.rb +16 -0
  60. data/test/rails-app/config/initializers/trailblazer.rb +2 -0
  61. data/test/rails-app/config/locales/en.yml +11 -1
  62. data/test/rails-app/config/master.key +1 -0
  63. data/test/rails-app/config/routes.rb +27 -4
  64. data/test/rails-app/db/schema.rb +15 -0
  65. data/test/rails-app/test/controllers/api_songs_controller_test.rb +87 -0
  66. data/test/rails-app/test/controllers/songs_controller_test.rb +152 -145
  67. data/test/rails-app/test/test_helper.rb +7 -1
  68. data/test/test_helper.rb +0 -2
  69. data/trailblazer-endpoint.gemspec +2 -1
  70. metadata +69 -24
  71. data/test/rails-app/config/initializers/cookies_serializer.rb +0 -5
  72. data/test/rails-app/config/initializers/new_framework_defaults.rb +0 -24
  73. data/test/rails-app/config/initializers/session_store.rb +0 -3
  74. data/test/rails-app/config/secrets.yml +0 -22
  75. data/test/rails-app/test/helpers/.keep +0 -0
  76. data/test/rails-app/test/integration/.keep +0 -0
  77. data/test/rails-app/test/mailers/.keep +0 -0
  78. data/test/rails-app/vendor/assets/javascripts/.keep +0 -0
  79. data/test/rails-app/vendor/assets/stylesheets/.keep +0 -0
@@ -0,0 +1,6 @@
1
+ class Song < Struct.new(:id)
2
+ def self.find_by(id: false)
3
+ return unless id
4
+ return Song.new(id)
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class User < Struct.new(:id, :email)
2
+ def self.find_by(id: false, email: false)
3
+ return User.new(1, "yogi@trb.to") if email == "yogi@trb.to"
4
+ return User.new(id, "yogi@trb.to") if id.to_s == "1"
5
+ return User.new(id, "seuros@trb.to") if id.to_s == "2"
6
+ end
7
+ end
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to setup or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?('config/database.yml')
22
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! 'bin/rails db:prepare'
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! 'bin/rails log:clear tmp:clear'
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! 'bin/rails restart'
33
+ end
@@ -1,6 +1,20 @@
1
+ require 'uri'
1
2
  require_relative 'boot'
2
3
 
3
- require 'rails/all'
4
+ require "rails"
5
+ # Pick the frameworks you want:
6
+ require "active_model/railtie"
7
+ # require "active_job/railtie"
8
+ require "active_record/railtie"
9
+ # require "active_storage/engine"
10
+ require "action_controller/railtie"
11
+ # require "action_mailer/railtie"
12
+ # require "action_mailbox/engine"
13
+ # require "action_text/engine"
14
+ # require "action_view/railtie"
15
+ # require "action_cable/engine"
16
+ # require "sprockets/railtie"
17
+ require "rails/test_unit/railtie"
4
18
 
5
19
  # Require the gems listed in Gemfile, including any gems
6
20
  # you've limited to :test, :development, or :production.
@@ -8,8 +22,17 @@ Bundler.require(*Rails.groups)
8
22
 
9
23
  module RailsApp
10
24
  class Application < Rails::Application
25
+ # Initialize configuration defaults for originally generated Rails version.
26
+ config.load_defaults 6.0
27
+
11
28
  # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
29
+ # Application configuration can go into files in config/initializers
30
+ # -- all .rb files in that directory are automatically loaded after loading
31
+ # the framework and any gems in your application.
32
+
33
+ # Only loads a smaller set of middleware suitable for API only apps.
34
+ # Middleware like session, flash, cookies can be added back manually.
35
+ # Skip views, helpers and assets when generating a new resource.
36
+ config.api_only = false
14
37
  end
15
38
  end
@@ -0,0 +1 @@
1
+ DrKH8tXT2zcMyRNuO17XGyj5qNwIUtoMDC6d+VfPQdJRIgRbfCd6tLY4N9AOkXXQP2e9DeJFgBPnfirNu4ixAoJmEwlnjhoobiMizxpbYgI9YLVhtCMyRNhQG9RsVfb4yoo6S4b9FEPlUmf0JKC4L/THuE15ro2tLBkx7dg+IYEz/oBe//xHqcD4wE1WYOJVzT53wpCWan6Ju+bdDmS9M7TmCPm6DQ0Kt9y+I350X5rUIPPTGO0akf3g+AkYRdEu/1Z6C8NmrmvBzcQ3UTRDUy+LubJ+JT342J/eQo1A480fhqDUTzWNUpYWD6zA0PRCKyaTaP4w/WvvPF6F6fmuHLDkMa1+TdX+rkLPIBbWYkba6DpVtwjLz+t5LUvk4BDNTfk59SNRQxC4jJOEWbxtU4rDopDCi/qGjP6i--fFGcdGkm4cR2s7ZR--3aMr7ojTm6N0V7CF/HjuHA==
@@ -1,4 +1,4 @@
1
- # SQLite version 3.x
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
2
  # gem install sqlite3
3
3
  #
4
4
  # Ensure the SQLite 3 gem is defined in your Gemfile
@@ -6,7 +6,7 @@
6
6
  #
7
7
  default: &default
8
8
  adapter: sqlite3
9
- pool: 5
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
10
  timeout: 5000
11
11
 
12
12
  development:
@@ -13,12 +13,11 @@ Rails.application.configure do
13
13
  config.consider_all_requests_local = true
14
14
 
15
15
  # Enable/disable caching. By default caching is disabled.
16
- if Rails.root.join('tmp/caching-dev.txt').exist?
17
- config.action_controller.perform_caching = true
18
-
16
+ # Run rails dev:cache to toggle caching.
17
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
19
18
  config.cache_store = :memory_store
20
19
  config.public_file_server.headers = {
21
- 'Cache-Control' => 'public, max-age=172800'
20
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
22
21
  }
23
22
  else
24
23
  config.action_controller.perform_caching = false
@@ -26,29 +25,20 @@ Rails.application.configure do
26
25
  config.cache_store = :null_store
27
26
  end
28
27
 
29
- # Don't care if the mailer can't send.
30
- config.action_mailer.raise_delivery_errors = false
31
-
32
- config.action_mailer.perform_caching = false
33
-
34
28
  # Print deprecation notices to the Rails logger.
35
29
  config.active_support.deprecation = :log
36
30
 
37
31
  # Raise an error on page load if there are pending migrations.
38
32
  config.active_record.migration_error = :page_load
39
33
 
40
- # Debug mode disables concatenation and preprocessing of assets.
41
- # This option may cause significant delays in view rendering with a large
42
- # number of complex assets.
43
- config.assets.debug = true
34
+ # Highlight code that triggered database queries in logs.
35
+ config.active_record.verbose_query_logs = true
44
36
 
45
- # Suppress logger output for asset requests.
46
- config.assets.quiet = true
47
37
 
48
- # Raises error for missing translations
38
+ # Raises error for missing translations.
49
39
  # config.action_view.raise_on_missing_translations = true
50
40
 
51
41
  # Use an evented file watcher to asynchronously detect changes in source code,
52
42
  # routes, locales, etc. This feature depends on the listen gem.
53
- config.file_watcher = ActiveSupport::EventedFileUpdateChecker
43
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54
44
  end
@@ -12,21 +12,15 @@ Rails.application.configure do
12
12
 
13
13
  # Full error reports are disabled and caching is turned on.
14
14
  config.consider_all_requests_local = false
15
- config.action_controller.perform_caching = true
15
+
16
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
17
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
18
+ # config.require_master_key = true
16
19
 
17
20
  # Disable serving static files from the `/public` folder by default since
18
21
  # Apache or NGINX already handles this.
19
22
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
23
 
21
- # Compress JavaScripts and CSS.
22
- config.assets.js_compressor = :uglifier
23
- # config.assets.css_compressor = :sass
24
-
25
- # Do not fallback to assets pipeline if a precompiled asset is missed.
26
- config.assets.compile = false
27
-
28
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29
-
30
24
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31
25
  # config.action_controller.asset_host = 'http://assets.example.com'
32
26
 
@@ -34,11 +28,6 @@ Rails.application.configure do
34
28
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35
29
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36
30
 
37
- # Mount Action Cable outside main process or domain
38
- # config.action_cable.mount_path = nil
39
- # config.action_cable.url = 'wss://example.com/cable'
40
- # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41
-
42
31
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
32
  # config.force_ssl = true
44
33
 
@@ -52,14 +41,9 @@ Rails.application.configure do
52
41
  # Use a different cache store in production.
53
42
  # config.cache_store = :mem_cache_store
54
43
 
55
- # Use a real queuing backend for Active Job (and separate queues per environment)
44
+ # Use a real queuing backend for Active Job (and separate queues per environment).
56
45
  # config.active_job.queue_adapter = :resque
57
- # config.active_job.queue_name_prefix = "rails-app_#{Rails.env}"
58
- config.action_mailer.perform_caching = false
59
-
60
- # Ignore bad email addresses and do not raise email delivery errors.
61
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62
- # config.action_mailer.raise_delivery_errors = false
46
+ # config.active_job.queue_name_prefix = "rails_app_production"
63
47
 
64
48
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65
49
  # the I18n.default_locale when a translation cannot be found).
@@ -78,9 +62,30 @@ Rails.application.configure do
78
62
  if ENV["RAILS_LOG_TO_STDOUT"].present?
79
63
  logger = ActiveSupport::Logger.new(STDOUT)
80
64
  logger.formatter = config.log_formatter
81
- config.logger = ActiveSupport::TaggedLogging.new(logger)
65
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
82
66
  end
83
67
 
84
68
  # Do not dump schema after migrations.
85
69
  config.active_record.dump_schema_after_migration = false
70
+
71
+ # Inserts middleware to perform automatic connection switching.
72
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
73
+ # middleware. The `delay` is used to determine how long to wait after a write
74
+ # to send a subsequent read to the primary.
75
+ #
76
+ # The `database_resolver` class is used by the middleware to determine which
77
+ # database is appropriate to use based on the time delay.
78
+ #
79
+ # The `database_resolver_context` class is used by the middleware to set
80
+ # timestamps for the last write to the primary. The resolver uses the context
81
+ # class timestamps to determine how long to wait before reading from the
82
+ # replica.
83
+ #
84
+ # By default Rails will store a last write timestamp in the session. The
85
+ # DatabaseSelector middleware is designed as such you can define your own
86
+ # strategy for connection switching and pass that into the middleware through
87
+ # these configuration options.
88
+ # config.active_record.database_selector = { delay: 2.seconds }
89
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
90
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
86
91
  end
@@ -1,10 +1,11 @@
1
+ # The test environment is used exclusively to run your application's
2
+ # test suite. You never need to work with it otherwise. Remember that
3
+ # your test database is "scratch space" for the test suite and is wiped
4
+ # and recreated between test runs. Don't rely on the data there!
5
+
1
6
  Rails.application.configure do
2
7
  # Settings specified here will take precedence over those in config/application.rb.
3
8
 
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
9
  config.cache_classes = true
9
10
 
10
11
  # Do not eager load code on boot. This avoids loading your whole application
@@ -15,28 +16,25 @@ Rails.application.configure do
15
16
  # Configure public file server for tests with Cache-Control for performance.
16
17
  config.public_file_server.enabled = true
17
18
  config.public_file_server.headers = {
18
- 'Cache-Control' => 'public, max-age=3600'
19
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
19
20
  }
20
21
 
21
22
  # Show full error reports and disable caching.
22
23
  config.consider_all_requests_local = true
23
24
  config.action_controller.perform_caching = false
25
+ config.cache_store = :null_store
24
26
 
25
27
  # Raise exceptions instead of rendering exception templates.
26
28
  config.action_dispatch.show_exceptions = false
27
29
 
28
30
  # Disable request forgery protection in test environment.
29
31
  config.action_controller.allow_forgery_protection = false
30
- config.action_mailer.perform_caching = false
31
-
32
- # Tell Action Mailer not to deliver emails to the real world.
33
- # The :test delivery method accumulates sent emails in the
34
- # ActionMailer::Base.deliveries array.
35
- config.action_mailer.delivery_method = :test
36
32
 
37
33
  # Print deprecation notices to the stderr.
38
34
  config.active_support.deprecation = :stderr
39
35
 
40
- # Raises error for missing translations
36
+ # Raises error for missing translations.
41
37
  # config.action_view.raise_on_missing_translations = true
38
+
39
+ config.cipher_key = "e1e1cc87asdfasdfasdfasfdasdfasdfasvhnfvbdb" # FIXME: this usually happens via the new key mechanism in Rails 6
42
40
  end
@@ -1,6 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # ApplicationController.renderer.defaults.merge!(
4
- # http_host: 'example.org',
5
- # https: false
6
- # )
3
+ # ActiveSupport::Reloader.to_prepare do
4
+ # ApplicationController.renderer.defaults.merge!(
5
+ # http_host: 'example.org',
6
+ # https: false
7
+ # )
8
+ # end
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Avoid CORS issues when API is called from the frontend app.
4
+ # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
5
+
6
+ # Read more: https://github.com/cyu/rack-cors
7
+
8
+ # Rails.application.config.middleware.insert_before 0, Rack::Cors do
9
+ # allow do
10
+ # origins 'example.com'
11
+ #
12
+ # resource '*',
13
+ # headers: :any,
14
+ # methods: [:get, :post, :put, :patch, :delete, :options, :head]
15
+ # end
16
+ # end