bidi2pdf-rails 0.0.1.alpha.1

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 (88) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +8 -0
  3. data/.idea/bidi2pdf-rails.iml +449 -0
  4. data/.idea/inspectionProfiles/profiles_settings.xml +5 -0
  5. data/.idea/misc.xml +4 -0
  6. data/.idea/modules.xml +8 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.rspec +3 -0
  9. data/.rubocop.yml +93 -0
  10. data/.ruby-gemset +1 -0
  11. data/.ruby-version +1 -0
  12. data/MIT-LICENSE +20 -0
  13. data/README.md +102 -0
  14. data/Rakefile +11 -0
  15. data/lib/bidi2pdf-rails.rb +4 -0
  16. data/lib/bidi2pdf_rails/browser_console_log_subscriber.rb +24 -0
  17. data/lib/bidi2pdf_rails/chromedriver_manager_singleton.rb +69 -0
  18. data/lib/bidi2pdf_rails/main_log_subscriber.rb +33 -0
  19. data/lib/bidi2pdf_rails/network_log_subscriber.rb +20 -0
  20. data/lib/bidi2pdf_rails/railtie.rb +44 -0
  21. data/lib/bidi2pdf_rails/services/html_renderer.rb +33 -0
  22. data/lib/bidi2pdf_rails/services/html_to_pdf_converter.rb +28 -0
  23. data/lib/bidi2pdf_rails/services/pdf_browser_session.rb +39 -0
  24. data/lib/bidi2pdf_rails/services/pdf_renderer.rb +81 -0
  25. data/lib/bidi2pdf_rails/services/url_to_pdf_converter.rb +82 -0
  26. data/lib/bidi2pdf_rails/version.rb +3 -0
  27. data/lib/bidi2pdf_rails.rb +141 -0
  28. data/lib/generators/bidi2pdf_rails/USAGE +8 -0
  29. data/lib/generators/bidi2pdf_rails/initializer_generator.rb +74 -0
  30. data/lib/generators/bidi2pdf_rails/templates/bidi2pdf_rails.rb.tt +121 -0
  31. data/spec/bidi2pdf_rails/bidi2pdf_rails_spec.rb +9 -0
  32. data/spec/dummy/Rakefile +6 -0
  33. data/spec/dummy/app/assets/images/img.jpg +0 -0
  34. data/spec/dummy/app/assets/javascripts/paged.polyfill-4.3.js +33251 -0
  35. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  36. data/spec/dummy/app/assets/stylesheets/pdf.css +121 -0
  37. data/spec/dummy/app/assets/stylesheets/reset.css +449 -0
  38. data/spec/dummy/app/assets/stylesheets/screen.css +281 -0
  39. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  40. data/spec/dummy/app/controllers/reports_controller.rb +12 -0
  41. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  42. data/spec/dummy/app/helpers/reports_helper.rb +2 -0
  43. data/spec/dummy/app/views/layouts/application.html.erb +67 -0
  44. data/spec/dummy/app/views/layouts/pdf.html.erb +67 -0
  45. data/spec/dummy/app/views/pwa/manifest.json.erb +22 -0
  46. data/spec/dummy/app/views/pwa/service-worker.js +26 -0
  47. data/spec/dummy/app/views/reports/show.html.erb +153 -0
  48. data/spec/dummy/bin/rails +4 -0
  49. data/spec/dummy/bin/rake +4 -0
  50. data/spec/dummy/bin/setup +29 -0
  51. data/spec/dummy/config/application.rb +40 -0
  52. data/spec/dummy/config/boot.rb +5 -0
  53. data/spec/dummy/config/environment.rb +5 -0
  54. data/spec/dummy/config/environments/development.rb +57 -0
  55. data/spec/dummy/config/environments/production.rb +73 -0
  56. data/spec/dummy/config/environments/test.rb +51 -0
  57. data/spec/dummy/config/initializers/bidi2pdf_rails.rb +68 -0
  58. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  59. data/spec/dummy/config/initializers/cors.rb +9 -0
  60. data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  61. data/spec/dummy/config/initializers/inflections.rb +16 -0
  62. data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
  63. data/spec/dummy/config/locales/en.yml +31 -0
  64. data/spec/dummy/config/puma.rb +34 -0
  65. data/spec/dummy/config/routes.rb +18 -0
  66. data/spec/dummy/config.ru +6 -0
  67. data/spec/dummy/log/development.log +12781 -0
  68. data/spec/dummy/public/404.html +67 -0
  69. data/spec/dummy/public/406-unsupported-browser.html +66 -0
  70. data/spec/dummy/public/422.html +67 -0
  71. data/spec/dummy/public/500.html +66 -0
  72. data/spec/dummy/public/icon.png +0 -0
  73. data/spec/dummy/public/icon.svg +3 -0
  74. data/spec/dummy/spec/helpers/reports_helper_spec.rb +15 -0
  75. data/spec/dummy/spec/requests/reports_spec.rb +10 -0
  76. data/spec/dummy/spec/views/reports/show.html.erb_spec.rb +5 -0
  77. data/spec/dummy/storage/test.sqlite3 +0 -0
  78. data/spec/dummy/tmp/README.md +69 -0
  79. data/spec/dummy/tmp/local_secret.txt +1 -0
  80. data/spec/dummy/tmp/pids/server.pid +1 -0
  81. data/spec/dummy/tmp/restart.txt +0 -0
  82. data/spec/generator/bidie2pdf_rails_initializer_generator_spec.rb +5 -0
  83. data/spec/generator/initializer_generator_spec.rb +5 -0
  84. data/spec/rails_helper.rb +60 -0
  85. data/spec/requests/reports_spec.rb +17 -0
  86. data/spec/spec_helper.rb +94 -0
  87. data/tasks/bidi2pdf_rails_tasks.rake +4 -0
  88. metadata +310 -0
@@ -0,0 +1,40 @@
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ # require "active_job/railtie"
7
+ # require "active_record/railtie"
8
+ # require "active_storage/engine"
9
+ require "action_controller/railtie"
10
+ # require "action_mailer/railtie"
11
+ # require "action_mailbox/engine"
12
+ # require "action_text/engine"
13
+ require "action_view/railtie"
14
+ # require "action_cable/engine"
15
+ require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
20
+
21
+ module Dummy
22
+ class Application < Rails::Application
23
+ config.load_defaults Rails::VERSION::STRING.to_f
24
+
25
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
26
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
27
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
28
+ config.autoload_lib(ignore: %w[assets tasks])
29
+
30
+ # Configuration for the application, engines, and railties goes here.
31
+ #
32
+ # These settings can be overridden in specific environments using the files
33
+ # in config/environments, which are processed later.
34
+ #
35
+ # config.time_zone = "Central Time (US & Canada)"
36
+ # config.eager_load_paths << Rails.root.join("extras")
37
+
38
+ config.assets.paths << Rails.root.join('app', 'assets')
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
+
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
+ $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,57 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.enable_reloading = true
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable server timing.
18
+ config.server_timing = true
19
+
20
+ # Enable/disable caching. By default caching is disabled.
21
+ # Run rails dev:cache to toggle caching.
22
+ if Rails.root.join("tmp/caching-dev.txt").exist?
23
+ config.action_controller.perform_caching = true
24
+ config.action_controller.enable_fragment_cache_logging = true
25
+
26
+ config.cache_store = :memory_store
27
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
28
+ else
29
+ config.action_controller.perform_caching = false
30
+
31
+ config.cache_store = :null_store
32
+ end
33
+
34
+ # Print deprecation notices to the Rails logger.
35
+ config.active_support.deprecation = :log
36
+
37
+ # Raise exceptions for disallowed deprecations.
38
+ config.active_support.disallowed_deprecation = :raise
39
+
40
+ # Tell Active Support which deprecation messages to disallow.
41
+ config.active_support.disallowed_deprecation_warnings = []
42
+
43
+ # Raises error for missing translations.
44
+ # config.i18n.raise_on_missing_translations = true
45
+
46
+ # Annotate rendered view with file names.
47
+ config.action_view.annotate_rendered_view_with_filenames = true
48
+
49
+ # Raise error when a before_action's only/except options reference missing actions.
50
+ config.action_controller.raise_on_missing_callback_actions = true
51
+
52
+ # Custom Bidi2PDF settings, check config/initializers/bidi2pdf_rails.rb for hints
53
+ config.x.bidi2pdf_rails.headless = false
54
+ config.x.bidi2pdf_rails.verbosity = :high
55
+ # config.x.bidi2pdf_rails.log_browser_console = true
56
+ # config.x.bidi2pdf_rails.default_timeout = 60
57
+ end
@@ -0,0 +1,73 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.enable_reloading = false
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
20
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
21
+ # config.require_master_key = true
22
+
23
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24
+ # config.public_file_server.enabled = false
25
+
26
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
27
+ # config.asset_host = "http://assets.example.com"
28
+
29
+ # Specifies the header that your server uses for sending files.
30
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
31
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
32
+
33
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
34
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
35
+ # config.assume_ssl = true
36
+
37
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
38
+ config.force_ssl = true
39
+
40
+ # Skip http-to-https redirect for the default health check endpoint.
41
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
42
+
43
+ # Log to STDOUT by default
44
+ config.logger = ActiveSupport::Logger.new(STDOUT)
45
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
46
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
47
+
48
+ # Prepend all log lines with the following tags.
49
+ config.log_tags = [:request_id]
50
+
51
+ # "info" includes generic and useful information about system operation, but avoids logging too much
52
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
53
+ # want to log everything, set the level to "debug".
54
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
55
+
56
+ # Use a different cache store in production.
57
+ # config.cache_store = :mem_cache_store
58
+
59
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
60
+ # the I18n.default_locale when a translation cannot be found).
61
+ config.i18n.fallbacks = true
62
+
63
+ # Don't log any deprecations.
64
+ config.active_support.report_deprecations = false
65
+
66
+ # Enable DNS rebinding protection and other `Host` header attacks.
67
+ # config.hosts = [
68
+ # "example.com", # Allow requests from example.com
69
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
70
+ # ]
71
+ # Skip DNS rebinding protection for the default health check endpoint.
72
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
73
+ end
@@ -0,0 +1,51 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
10
+
11
+ # While tests run files are not watched, reloading is not necessary.
12
+ config.enable_reloading = false
13
+
14
+ # Eager loading loads your entire application. When running a single test locally,
15
+ # this is usually not necessary, and can slow down your test suite. However, it's
16
+ # recommended that you enable it in continuous integration systems to ensure eager
17
+ # loading is working properly before deploying your code.
18
+ config.eager_load = ENV["CI"].present?
19
+
20
+ # Configure public file server for tests with Cache-Control for performance.
21
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
22
+
23
+ # Show full error reports and disable caching.
24
+ config.consider_all_requests_local = true
25
+ config.action_controller.perform_caching = false
26
+ config.cache_store = :null_store
27
+
28
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
29
+ config.action_dispatch.show_exceptions = :rescuable
30
+
31
+ # Disable request forgery protection in test environment.
32
+ config.action_controller.allow_forgery_protection = false
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raise exceptions for disallowed deprecations.
38
+ config.active_support.disallowed_deprecation = :raise
39
+
40
+ # Tell Active Support which deprecation messages to disallow.
41
+ config.active_support.disallowed_deprecation_warnings = []
42
+
43
+ # Raises error for missing translations.
44
+ # config.i18n.raise_on_missing_translations = true
45
+
46
+ # Annotate rendered view with file names.
47
+ # config.action_view.annotate_rendered_view_with_filenames = true
48
+
49
+ # Raise error when a before_action's only/except options reference missing actions.
50
+ config.action_controller.raise_on_missing_callback_actions = true
51
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ Bidi2pdfRails.configure do |config|
4
+ overrides = Rails.application.config.x.bidi2pdf_rails
5
+
6
+ config.notification_service = ActiveSupport::Notifications
7
+
8
+ config.logger = Rails.logger
9
+ config.verbosity = overrides.verbosity.nil? ? :none : overrides.verbosity
10
+ config.default_timeout = 10
11
+
12
+ # Chrome & BiDi
13
+ # config.remote_browser_url = nil
14
+ config.headless = overrides.headless.nil? ? false : overrides.headless
15
+ # config.chromedriver_port = 0
16
+ # config.chrome_session_args = [
17
+ # "--disable-gpu",
18
+ # "--no-sandbox"
19
+ # ]
20
+
21
+ # config.proxy_addr = nil
22
+ # config.proxy_port = nil
23
+ # config.proxy_user = nil
24
+ # config.proxy_pass = nil
25
+
26
+ # Viewport settings
27
+ # config.viewport_width = 1920
28
+ # config.viewport_height = 1080
29
+
30
+ # PDF settings
31
+ config.pdf_orientation = "portrait"
32
+ config.pdf_margin_top = 2.5
33
+ config.pdf_margin_bottom = 2.5
34
+ config.pdf_margin_left = 3
35
+ config.pdf_margin_right = 2
36
+ config.pdf_print_background = true
37
+ # config.pdf_scale = 1.0
38
+
39
+ # config.cookies = [
40
+ # { name: "session", value: "abc123", domain: "example.com" }
41
+ # ]
42
+
43
+ # config.headers = {
44
+ # "X-API-KEY" => "topsecret"
45
+ # }
46
+
47
+ # config.auth = {
48
+ # username: "admin",
49
+ # password: "secret"
50
+ # }
51
+
52
+ # chromedriver install dir
53
+ # config.install_dir = Rails.root.join("tmp", "bidi2pdf").to_s
54
+
55
+ # wait for the page to load settings
56
+ config.wait_for_network_idle = true
57
+ config.wait_for_page_loaded = true
58
+ # config.wait_for_page_check_script = nil
59
+ end
60
+
61
+ Rails.application.config.after_initialize do
62
+ Bidi2pdfRails::MainLogSubscriber.attach_to "bidi2pdf", inherit_all: true # needed for imported methods
63
+ Bidi2pdfRails::MainLogSubscriber.attach_to "bidi2pdf_rails", inherit_all: true # needed for imported methods
64
+ Bidi2pdfRails::BrowserConsoleLogSubscriber.attach_to "bidi2pdf"
65
+ Bidi2pdfRails::NetworkLogSubscriber.attach_to "bidi2pdf"
66
+
67
+ Bidi2pdfRails::MainLogSubscriber.silence /network_event_.*\.bidi2pdf/
68
+ end
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
+
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src style-src)
22
+ #
23
+ # # Report violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
25
+ # end
@@ -0,0 +1,9 @@
1
+ gem 'rack-cors'
2
+
3
+ # config/initializers/cors.rb
4
+ Rails.application.config.middleware.insert_before 0, Rack::Cors do
5
+ allow do
6
+ origins '*'
7
+ resource '/assets/*', headers: :any, methods: [:get, :options]
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4
+ # Use this to limit dissemination of sensitive information.
5
+ # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6
+ Rails.application.config.filter_parameters += [
7
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym "RESTful"
16
+ # end
@@ -0,0 +1,13 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide HTTP permissions policy. For further
4
+ # information see: https://developers.google.com/web/updates/2018/06/feature-policy
5
+
6
+ # Rails.application.config.permissions_policy do |policy|
7
+ # policy.camera :none
8
+ # policy.gyroscope :none
9
+ # policy.microphone :none
10
+ # policy.usb :none
11
+ # policy.fullscreen :self
12
+ # policy.payment :self, "https://secure.example.com"
13
+ # 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,34 @@
1
+ # This configuration file will be evaluated by Puma. The top-level methods that
2
+ # are invoked here are part of Puma's configuration DSL. For more information
3
+ # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
+
5
+ # Puma starts a configurable number of processes (workers) and each process
6
+ # serves each request in a thread from an internal thread pool.
7
+ #
8
+ # The ideal number of threads per worker depends both on how much time the
9
+ # application spends waiting for IO operations and on how much you wish to
10
+ # to prioritize throughput over latency.
11
+ #
12
+ # As a rule of thumb, increasing the number of threads will increase how much
13
+ # traffic a given process can handle (throughput), but due to CRuby's
14
+ # Global VM Lock (GVL) it has diminishing returns and will degrade the
15
+ # response time (latency) of the application.
16
+ #
17
+ # The default is set to 3 threads as it's deemed a decent compromise between
18
+ # throughput and latency for the average Rails application.
19
+ #
20
+ # Any libraries that use a connection pool or another resource pool should
21
+ # be configured to provide at least as many connections as the number of
22
+ # threads. This includes Active Record's `pool` parameter in `database.yml`.
23
+ threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
24
+ threads threads_count, threads_count
25
+
26
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
27
+ port ENV.fetch("PORT", 3000)
28
+
29
+ # Allow puma to be restarted by `bin/rails restart` command.
30
+ plugin :tmp_restart
31
+
32
+ # Specify the PID file. Defaults to tmp/pids/server.pid in development.
33
+ # In other environments, only set the PID file if requested.
34
+ pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
@@ -0,0 +1,18 @@
1
+ Rails.application.routes.draw do
2
+ get "reports/:id" => "reports#show", as: :report
3
+
4
+ get "print-remote" => "reports#print_remote", as: :print_remote
5
+
6
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
7
+
8
+ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
9
+ # Can be used by load balancers and uptime monitors to verify that the app is live.
10
+ get "up" => "rails/health#show", as: :rails_health_check
11
+
12
+ # Render dynamic PWA files from app/views/pwa/*
13
+ get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
14
+ get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
15
+
16
+ # Defines the root path route ("/")
17
+ # root "posts#index"
18
+ end
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server