my_api_client 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -6
- data/.rubocop.yml +4 -3
- data/.ruby-version +1 -0
- data/CHANGELOG.md +47 -0
- data/Gemfile.lock +65 -64
- data/README.jp.md +2 -2
- data/README.md +2 -2
- data/example/api_clients/my_error_api_client.rb +1 -1
- data/example/api_clients/my_header_api_client.rb +1 -1
- data/example/api_clients/my_pagination_api_client.rb +2 -2
- data/example/api_clients/my_rest_api_client.rb +10 -10
- data/example/api_clients/my_status_api_client.rb +1 -1
- data/gemfiles/rails_7.1.gemfile +15 -0
- data/gemfiles/rails_7.2.gemfile +15 -0
- data/lib/my_api_client/error_handling.rb +1 -1
- data/lib/my_api_client/errors/network_error.rb +1 -1
- data/lib/my_api_client/errors.rb +1 -1
- data/lib/my_api_client/exceptions.rb +1 -1
- data/lib/my_api_client/params/params.rb +1 -1
- data/lib/my_api_client/params/request.rb +8 -8
- data/lib/my_api_client/request/basic.rb +2 -2
- data/lib/my_api_client/request/executor.rb +1 -1
- data/lib/my_api_client/request/pagination.rb +1 -3
- data/lib/my_api_client/request.rb +5 -5
- data/lib/my_api_client/rspec/matcher_helper.rb +3 -3
- data/lib/my_api_client/rspec/matchers/request_to.rb +1 -1
- data/lib/my_api_client/version.rb +1 -1
- data/my_api/Gemfile +1 -1
- data/my_api/Gemfile.lock +53 -49
- data/my_api/app/controllers/error_controller.rb +1 -1
- data/my_api/app/controllers/pagination_controller.rb +1 -1
- data/my_api/app/controllers/rest_controller.rb +4 -4
- data/my_api/app/controllers/status_controller.rb +1 -1
- data/my_api/spec/controllers/error_controller_spec.rb +4 -4
- data/my_api/spec/controllers/status_controller_spec.rb +3 -3
- data/my_api_client.gemspec +2 -1
- data/rails_app/rails_6.1/Gemfile.lock +73 -71
- data/rails_app/rails_7.0/Gemfile.lock +78 -76
- data/rails_app/rails_7.1/.dockerignore +31 -0
- data/rails_app/rails_7.1/.rspec +1 -0
- data/rails_app/rails_7.1/Dockerfile +55 -0
- data/rails_app/rails_7.1/Gemfile +16 -0
- data/rails_app/rails_7.1/Gemfile.lock +241 -0
- data/rails_app/rails_7.1/README.md +24 -0
- data/rails_app/rails_7.1/Rakefile +8 -0
- data/rails_app/rails_7.1/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_7.1/app/controllers/concerns/.keep +0 -0
- data/rails_app/rails_7.1/app/models/application_record.rb +5 -0
- data/rails_app/rails_7.1/app/models/concerns/.keep +0 -0
- data/rails_app/rails_7.1/bin/bundle +122 -0
- data/rails_app/rails_7.1/bin/docker-entrypoint +8 -0
- data/rails_app/rails_7.1/bin/rails +6 -0
- data/rails_app/rails_7.1/bin/rake +6 -0
- data/rails_app/rails_7.1/bin/setup +35 -0
- data/rails_app/rails_7.1/config/application.rb +46 -0
- data/rails_app/rails_7.1/config/boot.rb +5 -0
- data/rails_app/rails_7.1/config/credentials.yml.enc +1 -0
- data/rails_app/rails_7.1/config/database.yml +25 -0
- data/rails_app/rails_7.1/config/environment.rb +7 -0
- data/rails_app/rails_7.1/config/environments/development.rb +58 -0
- data/rails_app/rails_7.1/config/environments/production.rb +74 -0
- data/rails_app/rails_7.1/config/environments/test.rb +56 -0
- data/rails_app/rails_7.1/config/initializers/cors.rb +17 -0
- data/rails_app/rails_7.1/config/initializers/filter_parameter_logging.rb +10 -0
- data/rails_app/rails_7.1/config/initializers/inflections.rb +17 -0
- data/rails_app/rails_7.1/config/locales/en.yml +31 -0
- data/rails_app/rails_7.1/config/puma.rb +46 -0
- data/rails_app/rails_7.1/config/routes.rb +12 -0
- data/rails_app/rails_7.1/config.ru +8 -0
- data/rails_app/rails_7.1/db/seeds.rb +10 -0
- data/rails_app/rails_7.1/lib/tasks/.keep +0 -0
- data/rails_app/rails_7.1/public/robots.txt +2 -0
- data/rails_app/rails_7.1/spec/rails_helper.rb +13 -0
- data/rails_app/rails_7.1/spec/spec_helper.rb +13 -0
- data/rails_app/rails_7.1/storage/.keep +0 -0
- data/rails_app/rails_7.1/tmp/.keep +0 -0
- data/rails_app/rails_7.1/tmp/pids/.keep +0 -0
- data/rails_app/rails_7.1/tmp/storage/.keep +0 -0
- data/rails_app/rails_7.1/vendor/.keep +0 -0
- data/rails_app/rails_7.2/.dockerignore +42 -0
- data/rails_app/rails_7.2/.github/dependabot.yml +12 -0
- data/rails_app/rails_7.2/.github/workflows/ci.yml +55 -0
- data/rails_app/rails_7.2/.rspec +1 -0
- data/rails_app/rails_7.2/Dockerfile +62 -0
- data/rails_app/rails_7.2/Gemfile +15 -0
- data/rails_app/rails_7.2/Gemfile.lock +240 -0
- data/rails_app/rails_7.2/README.md +24 -0
- data/rails_app/rails_7.2/Rakefile +8 -0
- data/rails_app/rails_7.2/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_7.2/app/controllers/concerns/.keep +0 -0
- data/rails_app/rails_7.2/app/models/application_record.rb +5 -0
- data/rails_app/rails_7.2/app/models/concerns/.keep +0 -0
- data/rails_app/rails_7.2/bin/brakeman +9 -0
- data/rails_app/rails_7.2/bin/bundle +122 -0
- data/rails_app/rails_7.2/bin/docker-entrypoint +13 -0
- data/rails_app/rails_7.2/bin/rails +6 -0
- data/rails_app/rails_7.2/bin/rake +6 -0
- data/rails_app/rails_7.2/bin/rubocop +10 -0
- data/rails_app/rails_7.2/bin/setup +39 -0
- data/rails_app/rails_7.2/config/application.rb +46 -0
- data/rails_app/rails_7.2/config/boot.rb +5 -0
- data/rails_app/rails_7.2/config/credentials.yml.enc +1 -0
- data/rails_app/rails_7.2/config/database.yml +32 -0
- data/rails_app/rails_7.2/config/environment.rb +7 -0
- data/rails_app/rails_7.2/config/environments/development.rb +59 -0
- data/rails_app/rails_7.2/config/environments/production.rb +77 -0
- data/rails_app/rails_7.2/config/environments/test.rb +53 -0
- data/rails_app/rails_7.2/config/initializers/cors.rb +18 -0
- data/rails_app/rails_7.2/config/initializers/filter_parameter_logging.rb +10 -0
- data/rails_app/rails_7.2/config/initializers/inflections.rb +18 -0
- data/rails_app/rails_7.2/config/locales/en.yml +31 -0
- data/rails_app/rails_7.2/config/puma.rb +36 -0
- data/rails_app/rails_7.2/config/routes.rb +12 -0
- data/rails_app/rails_7.2/config.ru +8 -0
- data/rails_app/rails_7.2/db/seeds.rb +11 -0
- data/rails_app/rails_7.2/lib/tasks/.keep +0 -0
- data/rails_app/rails_7.2/public/robots.txt +3 -0
- data/rails_app/rails_7.2/spec/rails_helper.rb +13 -0
- data/rails_app/rails_7.2/spec/spec_helper.rb +13 -0
- data/rails_app/rails_7.2/storage/.keep +0 -0
- data/rails_app/rails_7.2/tmp/.keep +0 -0
- data/rails_app/rails_7.2/tmp/pids/.keep +0 -0
- data/rails_app/rails_7.2/tmp/storage/.keep +0 -0
- data/rails_app/rails_7.2/vendor/.keep +0 -0
- metadata +107 -4
@@ -0,0 +1,122 @@
|
|
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($PROGRAM_NAME) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV.fetch('BUNDLER_VERSION', nil)
|
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
|
+
|
28
|
+
bundler_version = nil
|
29
|
+
update_index = nil
|
30
|
+
ARGV.each_with_index do |a, i|
|
31
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
32
|
+
bundler_version = a
|
33
|
+
end
|
34
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
|
35
|
+
|
36
|
+
bundler_version = Regexp.last_match(1)
|
37
|
+
update_index = i
|
38
|
+
end
|
39
|
+
bundler_version
|
40
|
+
end
|
41
|
+
|
42
|
+
def gemfile
|
43
|
+
gemfile = ENV.fetch('BUNDLE_GEMFILE', nil)
|
44
|
+
return gemfile if gemfile && !gemfile.empty?
|
45
|
+
|
46
|
+
File.expand_path('../Gemfile', __dir__)
|
47
|
+
end
|
48
|
+
|
49
|
+
def lockfile
|
50
|
+
lockfile =
|
51
|
+
case File.basename(gemfile)
|
52
|
+
when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile)
|
53
|
+
else "#{gemfile}.lock"
|
54
|
+
end
|
55
|
+
File.expand_path(lockfile)
|
56
|
+
end
|
57
|
+
|
58
|
+
def lockfile_version
|
59
|
+
return unless File.file?(lockfile)
|
60
|
+
|
61
|
+
lockfile_contents = File.read(lockfile)
|
62
|
+
unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
|
63
|
+
return
|
64
|
+
end
|
65
|
+
|
66
|
+
Regexp.last_match(1)
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
@bundler_requirement ||=
|
71
|
+
env_var_version || cli_arg_version ||
|
72
|
+
bundler_requirement_for(lockfile_version)
|
73
|
+
end
|
74
|
+
|
75
|
+
def bundler_requirement_for(version)
|
76
|
+
return "#{Gem::Requirement.default}.a" unless version
|
77
|
+
|
78
|
+
bundler_gem_version = Gem::Version.new(version)
|
79
|
+
|
80
|
+
requirement = bundler_gem_version.approximate_recommendation
|
81
|
+
|
82
|
+
return requirement unless Gem.rubygems_version < Gem::Version.new('2.7.0')
|
83
|
+
|
84
|
+
requirement += '.a' if bundler_gem_version.prerelease?
|
85
|
+
|
86
|
+
requirement
|
87
|
+
end
|
88
|
+
|
89
|
+
def load_bundler!
|
90
|
+
ENV['BUNDLE_GEMFILE'] ||= gemfile
|
91
|
+
|
92
|
+
activate_bundler
|
93
|
+
end
|
94
|
+
|
95
|
+
def activate_bundler
|
96
|
+
gem_error = activation_error_handling do
|
97
|
+
gem 'bundler', bundler_requirement
|
98
|
+
end
|
99
|
+
return if gem_error.nil?
|
100
|
+
|
101
|
+
require_error = activation_error_handling do
|
102
|
+
require 'bundler/version'
|
103
|
+
end
|
104
|
+
if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
105
|
+
return
|
106
|
+
end
|
107
|
+
|
108
|
+
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}'`"
|
109
|
+
exit 42
|
110
|
+
end
|
111
|
+
|
112
|
+
def activation_error_handling
|
113
|
+
yield
|
114
|
+
nil
|
115
|
+
rescue StandardError, LoadError => e
|
116
|
+
e
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
m.load_bundler!
|
121
|
+
|
122
|
+
load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args, exception: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
FileUtils.chdir APP_ROOT do
|
14
|
+
# This script is a way to set up or update your development environment automatically.
|
15
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
16
|
+
# Add necessary setup steps to this file.
|
17
|
+
|
18
|
+
puts '== Installing dependencies =='
|
19
|
+
system! 'gem install bundler --conservative'
|
20
|
+
system('bundle check') || system!('bundle install')
|
21
|
+
|
22
|
+
# puts "\n== Copying sample files =="
|
23
|
+
# unless File.exist?("config/database.yml")
|
24
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
25
|
+
# end
|
26
|
+
|
27
|
+
puts "\n== Preparing database =="
|
28
|
+
system! 'bin/rails db:prepare'
|
29
|
+
|
30
|
+
puts "\n== Removing old logs and tempfiles =="
|
31
|
+
system! 'bin/rails log:clear tmp:clear'
|
32
|
+
|
33
|
+
puts "\n== Restarting application server =="
|
34
|
+
system! 'bin/rails restart'
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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 Rails71
|
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`, for example.
|
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
|
+
end
|
46
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
tFnndSiXz8i0445d+z1JMwWVHJWVqBWvBxso+pMBFWMTIbZ3kXKdLyx259VUxRWvIIVpGBJPRRLlJv5fLf8a8dgFyjzLnXvaLlrchLCKoa6ivVQGH8/eQV8rxF218m5DiZLHK3TqN+nXSU3dOCDWY20fDtG7EBUgBliPCF3WftJv7HxGBGwilorbL3coS5A9cU0G2DFmK/PNkc+E2JTVOMjLjvqHslNf7pH64SwGE9mptHiVTe/tt+tTHTmEWrfm5Itk2nNKTC4Zm3wrbf1rAMbQWmKjC82COMqzTAgBaVY3tRR+IV+HMrZkCIEEnr6Xl2B8BOHtcMykTHHvTn+sHu/T/D3iBJChHujfd8K6S6hRnNXyoQh0Y+2N+aNNpg93JeNtYvcfe2CLm5E8k736ZuYKPFsy--3mZap9HcRKd3aQdC--lfdXoF8GfxlYXr+a84PV6w==
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite. Versions 3.8.0 and up are supported.
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem "sqlite3"
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: storage/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: storage/test.sqlite3
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: storage/production.sqlite3
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/integer/time'
|
4
|
+
|
5
|
+
Rails.application.configure do
|
6
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
7
|
+
|
8
|
+
# In the development environment your application's code is reloaded any time
|
9
|
+
# it changes. This slows down response time but is perfect for development
|
10
|
+
# since you don't have to restart the web server when you make code changes.
|
11
|
+
config.enable_reloading = true
|
12
|
+
|
13
|
+
# Do not eager load code on boot.
|
14
|
+
config.eager_load = false
|
15
|
+
|
16
|
+
# Show full error reports.
|
17
|
+
config.consider_all_requests_local = true
|
18
|
+
|
19
|
+
# Enable server timing
|
20
|
+
config.server_timing = true
|
21
|
+
|
22
|
+
# Enable/disable caching. By default caching is disabled.
|
23
|
+
# Run rails dev:cache to toggle caching.
|
24
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
25
|
+
config.cache_store = :memory_store
|
26
|
+
config.public_file_server.headers = {
|
27
|
+
'Cache-Control' => "public, max-age=#{2.days.to_i}",
|
28
|
+
}
|
29
|
+
else
|
30
|
+
config.action_controller.perform_caching = false
|
31
|
+
|
32
|
+
config.cache_store = :null_store
|
33
|
+
end
|
34
|
+
|
35
|
+
# Print deprecation notices to the Rails logger.
|
36
|
+
config.active_support.deprecation = :log
|
37
|
+
|
38
|
+
# Raise exceptions for disallowed deprecations.
|
39
|
+
config.active_support.disallowed_deprecation = :raise
|
40
|
+
|
41
|
+
# Tell Active Support which deprecation messages to disallow.
|
42
|
+
config.active_support.disallowed_deprecation_warnings = []
|
43
|
+
|
44
|
+
# Raise an error on page load if there are pending migrations.
|
45
|
+
config.active_record.migration_error = :page_load
|
46
|
+
|
47
|
+
# Highlight code that triggered database queries in logs.
|
48
|
+
config.active_record.verbose_query_logs = true
|
49
|
+
|
50
|
+
# Raises error for missing translations.
|
51
|
+
# config.i18n.raise_on_missing_translations = true
|
52
|
+
|
53
|
+
# Annotate rendered view with file names.
|
54
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
55
|
+
|
56
|
+
# Raise error when a before_action's only/except options reference missing actions
|
57
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
58
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/integer/time'
|
4
|
+
|
5
|
+
Rails.application.configure do
|
6
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
7
|
+
|
8
|
+
# Code is not reloaded between requests.
|
9
|
+
config.enable_reloading = false
|
10
|
+
|
11
|
+
# Eager load code on boot. This eager loads most of Rails and
|
12
|
+
# your application in memory, allowing both threaded web servers
|
13
|
+
# and those relying on copy on write to perform better.
|
14
|
+
# Rake tasks automatically ignore this option for performance.
|
15
|
+
config.eager_load = true
|
16
|
+
|
17
|
+
# Full error reports are disabled and caching is turned on.
|
18
|
+
config.consider_all_requests_local = false
|
19
|
+
|
20
|
+
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
|
21
|
+
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
|
22
|
+
# config.require_master_key = true
|
23
|
+
|
24
|
+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
25
|
+
# config.public_file_server.enabled = false
|
26
|
+
|
27
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
28
|
+
# config.asset_host = "http://assets.example.com"
|
29
|
+
|
30
|
+
# Specifies the header that your server uses for sending files.
|
31
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
32
|
+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
33
|
+
|
34
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
35
|
+
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
|
36
|
+
# config.assume_ssl = true
|
37
|
+
|
38
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
39
|
+
config.force_ssl = true
|
40
|
+
|
41
|
+
# Log to STDOUT by default
|
42
|
+
config.logger = ActiveSupport::Logger.new($stdout)
|
43
|
+
.tap { |logger| logger.formatter = Logger::Formatter.new }
|
44
|
+
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
45
|
+
|
46
|
+
# Prepend all log lines with the following tags.
|
47
|
+
config.log_tags = [:request_id]
|
48
|
+
|
49
|
+
# "info" includes generic and useful information about system operation, but avoids logging too much
|
50
|
+
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
51
|
+
# want to log everything, set the level to "debug".
|
52
|
+
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Don't log any deprecations.
|
62
|
+
config.active_support.report_deprecations = false
|
63
|
+
|
64
|
+
# Do not dump schema after migrations.
|
65
|
+
config.active_record.dump_schema_after_migration = false
|
66
|
+
|
67
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
68
|
+
# config.hosts = [
|
69
|
+
# "example.com", # Allow requests from example.com
|
70
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
71
|
+
# ]
|
72
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
73
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
74
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/integer/time'
|
4
|
+
|
5
|
+
# The test environment is used exclusively to run your application's
|
6
|
+
# test suite. You never need to work with it otherwise. Remember that
|
7
|
+
# your test database is "scratch space" for the test suite and is wiped
|
8
|
+
# and recreated between test runs. Don't rely on the data there!
|
9
|
+
|
10
|
+
Rails.application.configure do
|
11
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
12
|
+
|
13
|
+
# While tests run files are not watched, reloading is not necessary.
|
14
|
+
config.enable_reloading = false
|
15
|
+
|
16
|
+
# Eager loading loads your entire application. When running a single test locally,
|
17
|
+
# this is usually not necessary, and can slow down your test suite. However, it's
|
18
|
+
# recommended that you enable it in continuous integration systems to ensure eager
|
19
|
+
# loading is working properly before deploying your code.
|
20
|
+
config.eager_load = ENV['CI'].present?
|
21
|
+
|
22
|
+
# Configure public file server for tests with Cache-Control for performance.
|
23
|
+
config.public_file_server.enabled = true
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}",
|
26
|
+
}
|
27
|
+
|
28
|
+
# Show full error reports and disable caching.
|
29
|
+
config.consider_all_requests_local = true
|
30
|
+
config.action_controller.perform_caching = false
|
31
|
+
config.cache_store = :null_store
|
32
|
+
|
33
|
+
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
34
|
+
config.action_dispatch.show_exceptions = :rescuable
|
35
|
+
|
36
|
+
# Disable request forgery protection in test environment.
|
37
|
+
config.action_controller.allow_forgery_protection = false
|
38
|
+
|
39
|
+
# Print deprecation notices to the stderr.
|
40
|
+
config.active_support.deprecation = :stderr
|
41
|
+
|
42
|
+
# Raise exceptions for disallowed deprecations.
|
43
|
+
config.active_support.disallowed_deprecation = :raise
|
44
|
+
|
45
|
+
# Tell Active Support which deprecation messages to disallow.
|
46
|
+
config.active_support.disallowed_deprecation_warnings = []
|
47
|
+
|
48
|
+
# Raises error for missing translations.
|
49
|
+
# config.i18n.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Annotate rendered view with file names.
|
52
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
53
|
+
|
54
|
+
# Raise error when a before_action's only/except options reference missing actions
|
55
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Avoid CORS issues when API is called from the frontend app.
|
5
|
+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
|
6
|
+
|
7
|
+
# Read more: https://github.com/cyu/rack-cors
|
8
|
+
|
9
|
+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
10
|
+
# allow do
|
11
|
+
# origins "example.com"
|
12
|
+
#
|
13
|
+
# resource "*",
|
14
|
+
# headers: :any,
|
15
|
+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
16
|
+
# end
|
17
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
6
|
+
# Use this to limit dissemination of sensitive information.
|
7
|
+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
8
|
+
Rails.application.config.filter_parameters += %i[
|
9
|
+
passw secret token _key crypt salt certificate otp ssn
|
10
|
+
]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Add new inflection rules using the following format. Inflections
|
5
|
+
# are locale specific, and you may define rules for as many different
|
6
|
+
# locales as you wish. All of these examples are active by default:
|
7
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
8
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
9
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
10
|
+
# inflect.irregular "person", "people"
|
11
|
+
# inflect.uncountable %w( fish sheep )
|
12
|
+
# end
|
13
|
+
|
14
|
+
# These inflection rules are supported but not enabled by default:
|
15
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
16
|
+
# inflect.acronym "RESTful"
|
17
|
+
# end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization and
|
2
|
+
# are automatically loaded by Rails. If you want to use locales other than
|
3
|
+
# English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t "hello"
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t("hello") %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more about the API, please read the Rails Internationalization guide
|
20
|
+
# at https://guides.rubyonrails.org/i18n.html.
|
21
|
+
#
|
22
|
+
# Be aware that YAML interprets the following case-insensitive strings as
|
23
|
+
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
24
|
+
# must be quoted to be interpreted as strings. For example:
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# "yes": yup
|
28
|
+
# enabled: "ON"
|
29
|
+
|
30
|
+
en:
|
31
|
+
hello: "Hello world"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This configuration file will be evaluated by Puma. The top-level methods that
|
4
|
+
# are invoked here are part of Puma's configuration DSL. For more information
|
5
|
+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
6
|
+
|
7
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
8
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
9
|
+
# Any libraries that use thread pools should be configured to match
|
10
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
11
|
+
# and maximum; this matches the default thread size of Active Record.
|
12
|
+
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
|
13
|
+
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
|
14
|
+
threads min_threads_count, max_threads_count
|
15
|
+
|
16
|
+
rails_env = ENV.fetch('RAILS_ENV', 'development')
|
17
|
+
|
18
|
+
if rails_env == 'production'
|
19
|
+
# If you are running more than 1 thread per process, the workers count
|
20
|
+
# should be equal to the number of processors (CPU cores) in production.
|
21
|
+
#
|
22
|
+
# It defaults to 1 because it's impossible to reliably detect how many
|
23
|
+
# CPU cores are available. Make sure to set the `WEB_CONCURRENCY` environment
|
24
|
+
# variable to match the number of processors.
|
25
|
+
worker_count = Integer(ENV.fetch('WEB_CONCURRENCY', 1))
|
26
|
+
if worker_count > 1
|
27
|
+
workers worker_count
|
28
|
+
else
|
29
|
+
preload_app!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
33
|
+
# terminating a worker in development environments.
|
34
|
+
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
|
35
|
+
|
36
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
37
|
+
port ENV.fetch('PORT', 3000)
|
38
|
+
|
39
|
+
# Specifies the `environment` that Puma will run in.
|
40
|
+
environment rails_env
|
41
|
+
|
42
|
+
# Specifies the `pidfile` that Puma will use.
|
43
|
+
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
|
44
|
+
|
45
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
46
|
+
plugin :tmp_restart
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.routes.draw do
|
4
|
+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
5
|
+
|
6
|
+
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
7
|
+
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
8
|
+
get 'up' => 'rails/health#show', as: :rails_health_check
|
9
|
+
|
10
|
+
# Defines the root path route ("/")
|
11
|
+
# root "posts#index"
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# This file should ensure the existence of records required to run the application in every environment (production,
|
3
|
+
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
4
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
9
|
+
# MovieGenre.find_or_create_by!(name: genre_name)
|
10
|
+
# end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
ENV['RAILS_ENV'] ||= 'test'
|
5
|
+
require_relative '../config/environment'
|
6
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'my_api_client/rspec'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.infer_spec_type_from_file_location!
|
12
|
+
config.filter_rails_from_backtrace!
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
13
|
+
end
|
File without changes
|
File without changes
|
File without changes
|