diff --git a/bin/brakeman b/bin/brakeman
index 4b79003..ace1c9b 100755
--- a/bin/brakeman
+++ b/bin/brakeman
@@ -1,29 +1,7 @@
#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-#
-# This file was generated by Bundler.
-#
-# The application 'brakeman' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
-
-bundle_binstub = File.expand_path("../bundle", __FILE__)
-
-if File.file?(bundle_binstub)
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
- load(bundle_binstub)
- else
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
-Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
- end
-end
-
require "rubygems"
require "bundler/setup"
+ARGV.unshift("--ensure-latest")
+
load Gem.bin_path("brakeman", "brakeman")
diff --git a/bin/dev b/bin/dev
new file mode 100755
index 0000000..5f91c20
--- /dev/null
+++ b/bin/dev
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec "./bin/rails", "server", *ARGV
diff --git a/bin/rails b/bin/rails
index 6fb4e40..efc0377 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-APP_PATH = File.expand_path('../config/application', __dir__)
+APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
diff --git a/bin/rubocop b/bin/rubocop
new file mode 100755
index 0000000..40330c0
--- /dev/null
+++ b/bin/rubocop
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require "rubygems"
+require "bundler/setup"
+
+# explicit rubocop config increases performance slightly while avoiding config confusion.
+ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
+
+load Gem.bin_path("rubocop", "rubocop")
diff --git a/bin/setup b/bin/setup
index 90700ac..be3db3c 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,11 +1,10 @@
#!/usr/bin/env ruby
require "fileutils"
-# path to your application root.
-APP_ROOT = File.expand_path('..', __dir__)
+APP_ROOT = File.expand_path("..", __dir__)
def system!(*args)
- system(*args) || abort("\n== Command #{args} failed ==")
+ system(*args, exception: true)
end
FileUtils.chdir APP_ROOT do
@@ -13,24 +12,23 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.
- puts '== Installing dependencies =='
- system! 'gem install bundler --conservative'
- system('bundle check') || system!('bundle install')
-
- # Install JavaScript dependencies
- system! 'bin/yarn'
+ puts "== Installing dependencies =="
+ system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
- # unless File.exist?('config/database.yml')
- # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end
puts "\n== Preparing database =="
- system! 'bin/rails db:prepare'
+ system! "bin/rails db:prepare"
puts "\n== Removing old logs and tempfiles =="
- system! 'bin/rails log:clear tmp:clear'
+ system! "bin/rails log:clear tmp:clear"
- puts "\n== Restarting application server =="
- system! 'bin/rails restart'
+ unless ARGV.include?("--skip-server")
+ puts "\n== Starting development server =="
+ STDOUT.flush # flush the output before exec(2) so that it displays
+ exec "bin/dev"
+ end
end
diff --git a/bin/webpack b/bin/webpack
index 1031168..bbf8892 100755
--- a/bin/webpack
+++ b/bin/webpack
@@ -8,7 +8,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require "bundler/setup"
-
+require "logger"
require "webpacker"
require "webpacker/webpack_runner"
diff --git a/config/application.rb b/config/application.rb
index f54f76e..684c776 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,6 +1,3 @@
-require_relative '../lib/docker'
-Docker::Secret.setup_environment!
-
require_relative 'boot'
require 'rails/all'
@@ -12,12 +9,19 @@
module NewNara
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- config.load_defaults 6.0
+ config.load_defaults 8.0
- # ############################################################
- # Customize logging
+ # 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])
- require 'lib_it/logging'
- LibIT::Logging.configure!
+ # 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")
end
end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index a43bdb4..d1aa4de 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,9 +1,10 @@
+require 'active_support/core_ext/integer/time'
+
Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
- # In the development environment your application's code is reloaded on
- # every request. This slows down response time but is perfect for development
- # since you don't have to restart the web server when you make code changes.
- config.cache_classes = false
+ # Make code changes take effect immediately without server restart.
+ config.enable_reloading = true
# Do not eager load code on boot.
config.eager_load = false
@@ -11,30 +12,34 @@
# Show full error reports.
config.consider_all_requests_local = true
- # Enable/disable caching. By default caching is disabled.
- # Run rails dev:cache to toggle caching.
- if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ # Enable server timing.
+ config.server_timing = true
+
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
+ # Run rails dev:cache to toggle Action Controller caching.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
-
- config.cache_store = :memory_store
- config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{2.days.to_i}"
- }
+ config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
-
- config.cache_store = :null_store
end
+ # Change to :null_store to avoid any caching.
+ config.cache_store = :memory_store
+
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
+ # Make template changes take effect immediately.
config.action_mailer.perform_caching = false
+ # Set localhost to be used by links generated in mailer templates.
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
+
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
@@ -44,21 +49,28 @@
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
- # Debug mode disables concatenation and preprocessing of assets.
- # This option may cause significant delays in view rendering with a large
- # number of complex assets.
- config.assets.debug = true
+ # Append comments with runtime information tags to SQL queries in logs.
+ config.active_record.query_log_tags_enabled = true
- # Suppress logger output for asset requests.
- config.assets.quiet = true
- # Raises error for missing translations.
- # config.action_view.raise_on_missing_translations = true
+ # Highlight code that enqueued background job in logs.
+ config.active_job.verbose_enqueue_logs = true
- # Use an evented file watcher to asynchronously detect changes in source code,
- # routes, locales, etc. This feature depends on the listen gem.
- config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
# In development, bypass Rails 6 DNS rebinding attack protection
# to allow access by default hostname, container host, etc.
config.hosts.clear
+
+ # Annotate rendered view with file names.
+ config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Uncomment if you wish to allow Action Cable access from any origin.
+ # config.action_cable.disable_request_forgery_protection = true
+
+ # Raise error when a before_action's only/except options reference missing actions.
+ config.action_controller.raise_on_missing_callback_actions = true
+
+ # Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
+ # config.generators.apply_rubocop_autocorrect_after_generate!
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index a5ca612..6c41245 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,106 +1,89 @@
+require 'active_support/core_ext/integer/time'
+
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
- config.cache_classes = true
+ config.enable_reloading = false
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
config.eager_load = true
- # Full error reports are disabled and caching is turned on.
- config.consider_all_requests_local = false
- config.action_controller.perform_caching = true
+ # Full error reports are disabled.
+ config.consider_all_requests_local = false
- # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
- # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
- # config.require_master_key = true
+ # Turn on fragment caching in view templates.
+ config.action_controller.perform_caching = true
- # Disable serving static files from the `/public` folder by default since
- # Apache or NGINX already handles this.
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+ # Cache assets for far-future expiry since they are all digest stamped.
+ config.public_file_server.headers = { 'cache-control' => "public, max-age=#{1.year.to_i}" }
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
- # config.action_controller.asset_host = 'http://assets.example.com'
-
- # Specifies the header that your server uses for sending files.
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+ # config.asset_host = "http://assets.example.com"
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
- # Mount Action Cable outside main process or domain.
- # config.action_cable.mount_path = nil
- # config.action_cable.url = 'wss://example.com/cable'
- # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
+ config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
- config.force_ssl = false
+ config.force_ssl = true
- # Use the lowest log level to ensure availability of diagnostic information
- # when problems arise.
- config.log_level = :debug
+ # Skip http-to-https redirect for the default health check endpoint.
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
- # Prepend all log lines with the following tags.
+ # Log to STDOUT with the current request id as a default log tag.
config.log_tags = [:request_id]
+ config.logger = ActiveSupport::TaggedLogging.logger($stdout)
- # Use a different cache store in production.
- # config.cache_store = :mem_cache_store
+ # Change to "debug" to log everything (including potentially personally-identifiable information!)
+ config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
- # Use a real queuing backend for Active Job (and separate queues per environment).
- # config.active_job.queue_adapter = :resque
- # config.active_job.queue_name_prefix = "new_nara_production"
+ # Prevent health checks from clogging up the logs.
+ config.silence_healthcheck_path = '/up'
- config.action_mailer.perform_caching = false
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
+
+ # Replace the default in-process memory cache store with a durable alternative.
+ # config.cache_store = :mem_cache_store
+
+ # Replace the default in-process and non-durable queuing backend for Active Job.
+ # config.active_job.queue_adapter = :resque
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
+ # Set host to be used by links generated in mailer templates.
+ config.action_mailer.default_url_options = { host: 'example.com' }
+
+ # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
+ # config.action_mailer.smtp_settings = {
+ # user_name: Rails.application.credentials.dig(:smtp, :user_name),
+ # password: Rails.application.credentials.dig(:smtp, :password),
+ # address: "smtp.example.com",
+ # port: 587,
+ # authentication: :plain
+ # }
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
- # Send deprecation notices to registered listeners.
- config.active_support.deprecation = :notify
-
- # Use default logging formatter so that PID and timestamp are not suppressed.
- config.log_formatter = ::Logger::Formatter.new
-
- # Use a different logger for distributed setups.
- # require 'syslog/logger'
- # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
-
- if ENV['RAILS_LOG_TO_STDOUT'].present?
- logger = ActiveSupport::Logger.new($stdout)
- logger.formatter = config.log_formatter
- config.logger = ActiveSupport::TaggedLogging.new(logger)
- end
-
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
- # Inserts middleware to perform automatic connection switching.
- # The `database_selector` hash is used to pass options to the DatabaseSelector
- # middleware. The `delay` is used to determine how long to wait after a write
- # to send a subsequent read to the primary.
- #
- # The `database_resolver` class is used by the middleware to determine which
- # database is appropriate to use based on the time delay.
- #
- # The `database_resolver_context` class is used by the middleware to set
- # timestamps for the last write to the primary. The resolver uses the context
- # class timestamps to determine how long to wait before reading from the
- # replica.
+ # Only use :id for inspections in production.
+ config.active_record.attributes_for_inspect = [:id]
+
+ # Enable DNS rebinding protection and other `Host` header attacks.
+ # config.hosts = [
+ # "example.com", # Allow requests from example.com
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
+ # ]
#
- # By default Rails will store a last write timestamp in the session. The
- # DatabaseSelector middleware is designed as such you can define your own
- # strategy for connection switching and pass that into the middleware through
- # these configuration options.
- # config.active_record.database_selector = { delay: 2.seconds }
- # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
- # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
+ # Skip DNS rebinding protection for the default health check endpoint.
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index dc077a1..db22041 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -6,27 +6,25 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.hosts.clear
- config.cache_classes = false
- config.action_view.cache_template_loading = true
-
- # Do not eager load code on boot. This avoids loading your whole application
- # just for the purpose of running a single test. If you are using a tool that
- # preloads Rails for running tests, you may have to set it to true.
- config.eager_load = false
-
- # Configure public file server for tests with Cache-Control for performance.
- config.public_file_server.enabled = true
- config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
- }
-
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+
+ # While tests run files are not watched, reloading is not necessary.
+ config.enable_reloading = false
+
+ # Eager loading loads your entire application. When running a single test locally,
+ # this is usually not necessary, and can slow down your test suite. However, it's
+ # recommended that you enable it in continuous integration systems to ensure eager
+ # loading is working properly before deploying your code.
+ config.eager_load = ENV['CI'].present?
+
+ # Configure public file server for tests with cache-control for performance.
+ config.public_file_server.headers = { 'cache-control' => 'public, max-age=3600' }
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
config.cache_store = :null_store
- # Raise exceptions instead of rendering exception templates.
- config.action_dispatch.show_exceptions = false
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
+ config.action_dispatch.show_exceptions = :rescuable
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
@@ -34,16 +32,23 @@
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
- config.action_mailer.perform_caching = false
-
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
+ # Set host to be used by links generated in mailer templates.
+ config.action_mailer.default_url_options = { host: 'example.com' }
+
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations.
- # config.action_view.raise_on_missing_translations = true
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Raise error when a before_action's only/except options reference missing actions.
+ config.action_controller.raise_on_missing_callback_actions = true
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 0709a52..ee1f11b 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -5,10 +5,3 @@
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
-# Add Yarn node_modules folder to the asset load path.
-Rails.application.config.assets.paths << Rails.root.join('node_modules')
-
-# Precompile additional assets.
-# application.js, application.css, and all non-JS/CSS in the app/assets
-# folder are already added.
-# Rails.application.config.assets.precompile += %w( application.css )
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 35d0f26..b3076b3 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -1,30 +1,25 @@
# Be sure to restart your server when you modify this file.
-# Define an application-wide content security policy
-# For further information see the following documentation
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+# Define an application-wide content security policy.
+# See the Securing Rails Applications Guide for more information:
+# https://guides.rubyonrails.org/security.html#content-security-policy-header
-# Rails.application.config.content_security_policy do |policy|
-# policy.default_src :self, :https
-# policy.font_src :self, :https, :data
-# policy.img_src :self, :https, :data
-# policy.object_src :none
-# policy.script_src :self, :https
-# policy.style_src :self, :https
-# # If you are using webpack-dev-server then specify webpack-dev-server host
-# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
-
-# # Specify URI for violation reports
-# # policy.report_uri "/csp-violation-report-endpoint"
+# Rails.application.configure do
+# config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+#
+# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
+# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
+# config.content_security_policy_nonce_directives = %w(script-src style-src)
+#
+# # Report violations without enforcing the policy.
+# # config.content_security_policy_report_only = true
# end
-
-# If you are using UJS then enable automatic nonce generation
-# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
-
-# Set the nonce only to specific directives
-# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
-
-# Report CSP violations to a specified URI
-# For further information see the following documentation:
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
-# Rails.application.config.content_security_policy_report_only = true
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 4a994e1..f72dcdf 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -1,4 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += [:password]
+# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
+# Use this to limit dissemination of sensitive information.
+# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
+Rails.application.config.filter_parameters += %i[
+ passw email secret token _key crypt salt certificate otp ssn cvv cvc
+]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index ac033bf..3860f65 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -4,13 +4,13 @@
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.acronym 'RESTful'
+# inflect.acronym "RESTful"
# end
diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb
new file mode 100644
index 0000000..7db3b95
--- /dev/null
+++ b/config/initializers/permissions_policy.rb
@@ -0,0 +1,13 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide HTTP permissions policy. For further
+# information see: https://developers.google.com/web/updates/2018/06/feature-policy
+
+# Rails.application.config.permissions_policy do |policy|
+# policy.camera :none
+# policy.gyroscope :none
+# policy.microphone :none
+# policy.usb :none
+# policy.fullscreen :self
+# policy.payment :self, "https://secure.example.com"
+# end
diff --git a/config/puma.rb b/config/puma.rb
index 50f7d30..a248513 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,37 +1,41 @@
-# Puma can serve each request in a thread from an internal thread pool.
-# The `threads` method setting takes two numbers: a minimum and maximum.
-# Any libraries that use thread pools should be configured to match
-# the maximum value specified for Puma. Default is set to 5 threads for minimum
-# and maximum; this matches the default thread size of Active Record.
+# This configuration file will be evaluated by Puma. The top-level methods that
+# are invoked here are part of Puma's configuration DSL. For more information
+# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
-max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
-min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
-threads min_threads_count, max_threads_count
-
-# Bind to all interfaces (0.0.0.0) in all environments, not just production.
-bind ENV.fetch('PUMA_BINDING', 'tcp://0.0.0.0:3000')
-
-# Specifies the `environment` that Puma will run in.
+# Puma starts a configurable number of processes (workers) and each process
+# serves each request in a thread from an internal thread pool.
#
-environment ENV.fetch("RAILS_ENV") { "development" }
-
-# Specifies the `pidfile` that Puma will use.
-pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
-
-# Specifies the number of `workers` to boot in clustered mode.
-# Workers are forked web server processes. If using threads and workers together
-# the concurrency of the application would be max `threads` * `workers`.
-# Workers do not work on JRuby or Windows (both of which do not support
-# processes).
+# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
+# should only set this value when you want to run 2 or more workers. The
+# default is already 1.
#
-# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
-
-# Use the `preload_app!` method when specifying a `workers` number.
-# This directive tells Puma to first boot the application and load code
-# before forking the application. This takes advantage of Copy On Write
-# process behavior so workers use less memory.
+# The ideal number of threads per worker depends both on how much time the
+# application spends waiting for IO operations and on how much you wish to
+# prioritize throughput over latency.
#
-# preload_app!
+# As a rule of thumb, increasing the number of threads will increase how much
+# traffic a given process can handle (throughput), but due to CRuby's
+# Global VM Lock (GVL) it has diminishing returns and will degrade the
+# response time (latency) of the application.
+#
+# The default is set to 3 threads as it's deemed a decent compromise between
+# throughput and latency for the average Rails application.
+#
+# Any libraries that use a connection pool or another resource pool should
+# be configured to provide at least as many connections as the number of
+# threads. This includes Active Record's `pool` parameter in `database.yml`.
+threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+port ENV.fetch("PORT", 3000)
-# Allow puma to be restarted by `rails restart` command.
+# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
+
+# Run the Solid Queue supervisor inside of Puma for single-server deployments
+plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
+
+# Specify the PID file. Defaults to tmp/pids/server.pid in development.
+# In other environments, only set the PID file if requested.
+pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
diff --git a/db/schema.rb b/db/schema.rb
index ca74916..578e710 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 0) do
+ActiveRecord::Schema[6.1].define(version: 0) do
create_table "CPC", id: false, charset: "latin1", options: "ENGINE=MyISAM", force: :cascade do |t|
t.integer "ID"
diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml
index 10ceb7f..29638aa 100644
--- a/docker-compose.ci.yml
+++ b/docker-compose.ci.yml
@@ -6,6 +6,8 @@ services:
image: ${DOCKER_APP_IMAGE}
volumes: !override
- artifacts:/opt/app/artifacts
+ environment:
+ SECRET_KEY_BASE: ${SECRET_KEY_BASE:?error}
db:
volumes: !reset
diff --git a/lib/docker.rb b/lib/docker.rb
deleted file mode 100644
index ab23613..0000000
--- a/lib/docker.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Docker
- class Secret
- class << self
- def setup_environment!(fileglob = '/run/secrets/*')
- Dir[fileglob].each do |filepath|
- secret = File.read(filepath)
- secret_name = File.basename(filepath)
- ENV[secret_name] = secret unless secret.empty?
- end
- end
- end
- end
- end
diff --git a/lib/lib_it/logging.rb b/lib/lib_it/logging.rb
deleted file mode 100644
index a583817..0000000
--- a/lib/lib_it/logging.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'webpacker/instance'
-
-require 'lib_it/logging/events'
-require 'lib_it/logging/formatters'
-require 'lib_it/logging/loggers'
-
-module LibIT
- module Logging
- class << self
-
- # Configures custom logging for a Rails application.
- def configure!
- config = Rails.application.config
- configure_lograge!(config.lograge)
-
- logger = Loggers.new_default_logger
- logger.info("Custom logger initialized for environment #{Rails.env.inspect}")
-
- config.logger = logger
- Webpacker::Instance.logger = logger
- end
-
- private
-
- def configure_lograge!(lograge)
- return unless lograge
-
- lograge.enabled = true
- lograge.custom_options = Events.extract_data_for_lograge
- lograge.formatter = Formatters.lograge_formatter
- end
- end
- end
-end
diff --git a/lib/lib_it/logging/events.rb b/lib/lib_it/logging/events.rb
deleted file mode 100644
index 205adbf..0000000
--- a/lib/lib_it/logging/events.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module LibIT
- module Logging
- module Events
- class << self
- def extract_data_for_lograge
- ->(event) { extract_event_data(event) }
- end
-
- private
-
- def extract_event_data(event)
- event_data = { time: Time.now }
- extracted_headers = extract_headers(event)
- event_data.merge(extracted_headers)
- end
-
- def extract_headers(event)
- return {} unless (headers = event.payload[:headers])
-
- extracted_headers = {
- # yes, RFC 2616 uses a variant spelling for 'referrer', it's a known issue
- # https://tools.ietf.org/html/rfc2616#section-14.36
- referer: headers['HTTP_REFERER'],
- request_id: headers['action_dispatch.request_id'],
- remote_ip: headers['action_dispatch.remote_ip'],
- remote_addr: headers['REMOTE_ADDR'],
- x_forwarded_for: headers['HTTP_X_FORWARDED_FOR'],
- forwarded: headers['HTTP_FORWARDED'] # RFC 7239
- }
-
- # Some of these 'headers' include recursive structures
- # that cause SystemStackErrors in JSON serialization,
- # so we convert them all to strings
- extracted_headers.transform_values(&:to_s)
- end
- end
- end
- end
-end
diff --git a/lib/lib_it/logging/formatters.rb b/lib/lib_it/logging/formatters.rb
deleted file mode 100644
index 6916f46..0000000
--- a/lib/lib_it/logging/formatters.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-require 'ougai/formatters/bunyan'
-require 'ougai/formatters/readable'
-
-module Formatters
-
- class << self
- def new_json_formatter
- Bunyan.new
- end
-
- def new_readable_formatter
- Ougai::Formatters::Readable.new
- end
-
- def lograge_formatter
- Lograge.new
- end
-
- def ensure_hash(message)
- return {} unless message
- return message if message.is_a?(Hash)
-
- { msg: message }
- end
- end
-
- # ------------------------------------------------------------
- # Private helper classes
-
- class Bunyan < Ougai::Formatters::Bunyan
- include Ougai::Logging::Severity
-
- def _call(severity, time, progname, data)
- original_data = Formatters.ensure_hash(data)
-
- # Ougai::Formatters::Bunyan replaces the human-readable severity string
- # with a numeric level, so we add it here as a separate attribute
- severity = ensure_human_readable(severity)
- merged_data = { severity: severity }.merge(original_data)
- super(severity, time, progname, merged_data)
- end
-
- def ensure_human_readable(severity)
- return to_label(severity) if severity.is_a?(Integer)
-
- severity.to_s
- end
- end
- private_constant :Bunyan
-
- class Lograge
- def call(data)
- { msg: 'Request', request: Formatters.ensure_hash(data) }
- end
- end
- private_constant :Lograge
-
-end
diff --git a/lib/lib_it/logging/loggers.rb b/lib/lib_it/logging/loggers.rb
deleted file mode 100644
index e886290..0000000
--- a/lib/lib_it/logging/loggers.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require 'lib_it/logging/formatters'
-require 'lib_it/logging/tagged_logging_extensions'
-
-module LibIT
- module Logging
- module Loggers
- class << self
- def new_default_logger
- return new_test_logger if Rails.env.test?
- return new_production_logger if Rails.env.production?
- return new_development_logger if Rails.env.development?
- end
-
- def new_json_logger(logdev)
- new_logger_with(logdev: logdev, formatter: Formatters.new_json_formatter)
- end
-
- def new_readable_logger(logdev)
- new_logger_with(logdev: logdev, formatter: Formatters.new_readable_formatter)
- end
-
- private
-
- def new_test_logger
- file_logger_for_env(:test)
- end
-
- def new_production_logger
- new_json_logger($stdout)
- end
-
- def new_development_logger
- new_json_logger($stdout).tap do |json_logger|
- file_logger = file_logger_for_env(:dev)
- json_logger.extend Ougai::Logger.broadcast(file_logger)
- end
- end
-
- def file_logger_for_env(env)
- new_readable_logger("log/#{env}.log")
- end
-
- def new_logger_with(logdev:, formatter:)
- AvLogger.new(logdev).tap { |l| l.formatter = formatter }
- end
- end
-
- class AvLogger < Ougai::Logger
- include ActiveSupport::LoggerThreadSafeLevel
- include ActiveSupport::LoggerSilence
- end
- end
- end
-end
diff --git a/lib/lib_it/logging/tagged_logging_extensions.rb b/lib/lib_it/logging/tagged_logging_extensions.rb
deleted file mode 100644
index 1bf2e3c..0000000
--- a/lib/lib_it/logging/tagged_logging_extensions.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'active_support/tagged_logging'
-
-# Monkey-patch ActiveSupport::TaggedLogging::Formatter
-# not to produce garbage by prepending tags to hashes.
-module ActiveSupport
- module TaggedLogging
- module Formatter
- def call(severity, time, progname, data)
- return super unless current_tags.present?
-
- original_data = Formatters.ensure_hash(data)
- merged_data = { tags: current_tags }.merge(original_data)
- super(severity, time, progname, merged_data)
- end
- end
- end
-end
diff --git a/package.json b/package.json
index 8b9b5cc..48369de 100644
--- a/package.json
+++ b/package.json
@@ -13,5 +13,6 @@
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3"
- }
+ },
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
diff --git a/public/400.html b/public/400.html
new file mode 100644
index 0000000..282dbc8
--- /dev/null
+++ b/public/400.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+ The server cannot process the request due to a client error (400 Bad Request)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The server cannot process the request due to a client error. Please check the request and try again. If you’re the application owner check the logs for more information.
+
+
+
+
+
+
diff --git a/public/404.html b/public/404.html
index 9f832d1..c0670bc 100644
--- a/public/404.html
+++ b/public/404.html
@@ -1,69 +1,114 @@
-
-
-
- The page you were looking for doesn't exist (404)
-
-
-
-
-
-
-
-
-
The page you were looking for doesn't exist.
-
You may have mistyped the address or the page may have moved.
-
-
If you are the application owner check the logs for more information.
-
-
+
+
+
+
+
+
+ The page you were looking for doesn’t exist (404 Not found)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The page you were looking for doesn’t exist. You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.
+
+
+
+
+
diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html
new file mode 100644
index 0000000..9532a9c
--- /dev/null
+++ b/public/406-unsupported-browser.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+ Your browser is not supported (406 Not Acceptable)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Your browser is not supported. Please upgrade your browser to continue.
+
+
+
+
+
+
diff --git a/public/422.html b/public/422.html
index c08eac0..8bcf060 100644
--- a/public/422.html
+++ b/public/422.html
@@ -1,67 +1,114 @@
-
-
-
- The change you wanted was rejected (422)
-
-
-
-
-
-
-
-
-
The change you wanted was rejected.
-
Maybe you tried to change something you didn't have access to.
-
-
If you are the application owner check the logs for more information.
The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. If you’re the application owner check the logs for more information.