munster 0.1.0

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 (84) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +14 -0
  3. data/.standard.yml +3 -0
  4. data/CHANGELOG.md +3 -0
  5. data/LICENSE +21 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +39 -0
  8. data/Rakefile +18 -0
  9. data/config/routes.rb +3 -0
  10. data/example/.gitattributes +7 -0
  11. data/example/.gitignore +29 -0
  12. data/example/.ruby-version +1 -0
  13. data/example/Gemfile +32 -0
  14. data/example/Gemfile.lock +208 -0
  15. data/example/README.md +24 -0
  16. data/example/Rakefile +8 -0
  17. data/example/app/assets/images/.keep +0 -0
  18. data/example/app/assets/stylesheets/application.css +1 -0
  19. data/example/app/controllers/application_controller.rb +4 -0
  20. data/example/app/controllers/concerns/.keep +0 -0
  21. data/example/app/helpers/application_helper.rb +4 -0
  22. data/example/app/models/application_record.rb +5 -0
  23. data/example/app/models/concerns/.keep +0 -0
  24. data/example/app/views/layouts/application.html.erb +15 -0
  25. data/example/app/webhooks/test_handler.rb +28 -0
  26. data/example/bin/bundle +109 -0
  27. data/example/bin/rails +4 -0
  28. data/example/bin/rake +4 -0
  29. data/example/bin/setup +33 -0
  30. data/example/config/application.rb +39 -0
  31. data/example/config/boot.rb +5 -0
  32. data/example/config/credentials.yml.enc +1 -0
  33. data/example/config/database.yml +25 -0
  34. data/example/config/environment.rb +7 -0
  35. data/example/config/environments/development.rb +61 -0
  36. data/example/config/environments/production.rb +71 -0
  37. data/example/config/environments/test.rb +52 -0
  38. data/example/config/initializers/assets.rb +14 -0
  39. data/example/config/initializers/content_security_policy.rb +27 -0
  40. data/example/config/initializers/filter_parameter_logging.rb +10 -0
  41. data/example/config/initializers/generators.rb +7 -0
  42. data/example/config/initializers/inflections.rb +18 -0
  43. data/example/config/initializers/munster.rb +7 -0
  44. data/example/config/initializers/permissions_policy.rb +13 -0
  45. data/example/config/locales/en.yml +33 -0
  46. data/example/config/puma.rb +45 -0
  47. data/example/config/routes.rb +5 -0
  48. data/example/config.ru +8 -0
  49. data/example/db/migrate/20240523125859_create_munster_tables.rb +22 -0
  50. data/example/db/schema.rb +24 -0
  51. data/example/db/seeds.rb +9 -0
  52. data/example/lib/assets/.keep +0 -0
  53. data/example/lib/tasks/.keep +0 -0
  54. data/example/log/.keep +0 -0
  55. data/example/public/404.html +67 -0
  56. data/example/public/422.html +67 -0
  57. data/example/public/500.html +66 -0
  58. data/example/public/apple-touch-icon-precomposed.png +0 -0
  59. data/example/public/apple-touch-icon.png +0 -0
  60. data/example/public/favicon.ico +0 -0
  61. data/example/public/robots.txt +1 -0
  62. data/example/test/controllers/.keep +0 -0
  63. data/example/test/fixtures/files/.keep +0 -0
  64. data/example/test/helpers/.keep +0 -0
  65. data/example/test/integration/.keep +0 -0
  66. data/example/test/models/.keep +0 -0
  67. data/example/test/test_helper.rb +15 -0
  68. data/example/tmp/.keep +0 -0
  69. data/example/tmp/pids/.keep +0 -0
  70. data/example/vendor/.keep +0 -0
  71. data/lib/munster/base_handler.rb +67 -0
  72. data/lib/munster/controllers/receive_webhooks_controller.rb +52 -0
  73. data/lib/munster/engine.rb +22 -0
  74. data/lib/munster/install_generator.rb +30 -0
  75. data/lib/munster/jobs/processing_job.rb +14 -0
  76. data/lib/munster/models/received_webhook.rb +23 -0
  77. data/lib/munster/state_machine_enum.rb +125 -0
  78. data/lib/munster/templates/create_munster_tables.rb.erb +23 -0
  79. data/lib/munster/templates/munster.rb +4 -0
  80. data/lib/munster/version.rb +5 -0
  81. data/lib/munster.rb +23 -0
  82. data/lib/tasks/munster_tasks.rake +4 -0
  83. data/sig/munster.rbs +4 -0
  84. metadata +197 -0
data/example/bin/setup ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
@@ -0,0 +1,39 @@
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 Example
24
+ class Application < Rails::Application
25
+ # Initialize configuration defaults for originally generated Rails version.
26
+ config.load_defaults 7.0
27
+
28
+ # Configuration for the application, engines, and railties goes here.
29
+ #
30
+ # These settings can be overridden in specific environments using the files
31
+ # in config/environments, which are processed later.
32
+ #
33
+ # config.time_zone = "Central Time (US & Canada)"
34
+ # config.eager_load_paths << Rails.root.join("extras")
35
+
36
+ # Don't generate system test files.
37
+ config.generators.system_tests = nil
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
4
+
5
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -0,0 +1 @@
1
+ 0d+pK5hI19gsUs0UTyJcHVkOkyJ443ji4U3bIGPxJV66mTuU18mxLKbcog6QXxm5r0xOPzWDBPBlhqeyM/5Rs8dSQ/05aTGcG2oF1f6MYAJw2m+Hrfv4VmklvdAnJhHtXaEwR+WsxgkldpOsCphEFXMMP5ngkEkAG5SvxTl9gF+3ErVloDuFE0RJ50VzhpaZ027D36hwGqNtELR8hhE2cTLUGfy9bioVTT1OpSTjGQ6K33Pbz3RY8gVAo5+77qfd9TMVjwAtny+kYroPbOD4sQ8B2QeLClqXsbYm1EVxdxJr+E5XBwHoODSe6r6A7eEZkJCbScsj3oo1uSVBUaOFdVn/haL2X7kR7doGD3xXIzZ0oX8S5ye+A3YDWJY2DcxbnaCOVjgJwqmVGLTn3mscl3JzelpW59acGuw0--IJOzeBz9gkJU1TM6--xQ6jjXkjBKSSyzEQdDMoJQ==
@@ -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: db/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: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative "application"
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,61 @@
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.cache_classes = false
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.action_controller.perform_caching = true
26
+ config.action_controller.enable_fragment_cache_logging = true
27
+
28
+ config.cache_store = :memory_store
29
+ config.public_file_server.headers = {
30
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
31
+ }
32
+ else
33
+ config.action_controller.perform_caching = false
34
+
35
+ config.cache_store = :null_store
36
+ end
37
+
38
+ # Print deprecation notices to the Rails logger.
39
+ config.active_support.deprecation = :log
40
+
41
+ # Raise exceptions for disallowed deprecations.
42
+ config.active_support.disallowed_deprecation = :raise
43
+
44
+ # Tell Active Support which deprecation messages to disallow.
45
+ config.active_support.disallowed_deprecation_warnings = []
46
+
47
+ # Raise an error on page load if there are pending migrations.
48
+ config.active_record.migration_error = :page_load
49
+
50
+ # Highlight code that triggered database queries in logs.
51
+ config.active_record.verbose_query_logs = true
52
+
53
+ # Raises error for missing translations.
54
+ # config.i18n.raise_on_missing_translations = true
55
+
56
+ # Annotate rendered view with file names.
57
+ # config.action_view.annotate_rendered_view_with_filenames = true
58
+
59
+ # Uncomment if you wish to allow Action Cable access from any origin.
60
+ # config.action_cable.disable_request_forgery_protection = true
61
+ end
@@ -0,0 +1,71 @@
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.cache_classes = true
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
+ config.action_controller.perform_caching = true
20
+
21
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
22
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
23
+ # config.require_master_key = true
24
+
25
+ # Disable serving static files from the `/public` folder by default since
26
+ # Apache or NGINX already handles this.
27
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
28
+
29
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
30
+ # config.asset_host = "http://assets.example.com"
31
+
32
+ # Specifies the header that your server uses for sending files.
33
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
34
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
35
+
36
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
37
+ # config.force_ssl = true
38
+
39
+ # Include generic and useful information about system operation, but avoid logging too much
40
+ # information to avoid inadvertent exposure of personally identifiable information (PII).
41
+ config.log_level = :info
42
+
43
+ # Prepend all log lines with the following tags.
44
+ config.log_tags = [:request_id]
45
+
46
+ # Use a different cache store in production.
47
+ # config.cache_store = :mem_cache_store
48
+
49
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
50
+ # the I18n.default_locale when a translation cannot be found).
51
+ config.i18n.fallbacks = true
52
+
53
+ # Don't log any deprecations.
54
+ config.active_support.report_deprecations = false
55
+
56
+ # Use default logging formatter so that PID and timestamp are not suppressed.
57
+ config.log_formatter = ::Logger::Formatter.new
58
+
59
+ # Use a different logger for distributed setups.
60
+ # require "syslog/logger"
61
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
62
+
63
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
64
+ logger = ActiveSupport::Logger.new(STDOUT)
65
+ logger.formatter = config.log_formatter
66
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
67
+ end
68
+
69
+ # Do not dump schema after migrations.
70
+ config.active_record.dump_schema_after_migration = false
71
+ end
@@ -0,0 +1,52 @@
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
+ # Turn false under Spring and add config.action_view.cache_template_loading = true.
14
+ config.cache_classes = true
15
+
16
+ # Eager loading loads your whole application. When running a single test locally,
17
+ # this probably isn't necessary. It's a good idea to do in a continuous integration
18
+ # system, or in some way before deploying your code.
19
+ config.eager_load = ENV["CI"].present?
20
+
21
+ # Configure public file server for tests with Cache-Control for performance.
22
+ config.public_file_server.enabled = true
23
+ config.public_file_server.headers = {
24
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
25
+ }
26
+
27
+ # Show full error reports and disable caching.
28
+ config.consider_all_requests_local = true
29
+ config.action_controller.perform_caching = false
30
+ config.cache_store = :null_store
31
+
32
+ # Raise exceptions instead of rendering exception templates.
33
+ config.action_dispatch.show_exceptions = false
34
+
35
+ # Disable request forgery protection in test environment.
36
+ config.action_controller.allow_forgery_protection = false
37
+
38
+ # Print deprecation notices to the stderr.
39
+ config.active_support.deprecation = :stderr
40
+
41
+ # Raise exceptions for disallowed deprecations.
42
+ config.active_support.disallowed_deprecation = :raise
43
+
44
+ # Tell Active Support which deprecation messages to disallow.
45
+ config.active_support.disallowed_deprecation_warnings = []
46
+
47
+ # Raises error for missing translations.
48
+ # config.i18n.raise_on_missing_translations = true
49
+
50
+ # Annotate rendered view with file names.
51
+ # config.action_view.annotate_rendered_view_with_filenames = true
52
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Version of your assets, change this if you want to expire all your assets.
6
+ Rails.application.config.assets.version = "1.0"
7
+
8
+ # Add additional assets to the asset load path.
9
+ # Rails.application.config.assets.paths << Emoji.images_path
10
+
11
+ # Precompile additional assets.
12
+ # application.js, application.css, and all non-JS/CSS in the app/assets
13
+ # folder are already added.
14
+ # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Define an application-wide content security policy.
6
+ # See the Securing Rails Applications Guide for more information:
7
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
8
+
9
+ # Rails.application.configure do
10
+ # config.content_security_policy do |policy|
11
+ # policy.default_src :self, :https
12
+ # policy.font_src :self, :https, :data
13
+ # policy.img_src :self, :https, :data
14
+ # policy.object_src :none
15
+ # policy.script_src :self, :https
16
+ # policy.style_src :self, :https
17
+ # # Specify URI for violation reports
18
+ # # policy.report_uri "/csp-violation-report-endpoint"
19
+ # end
20
+ #
21
+ # # Generate session nonces for permitted importmap and inline scripts
22
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
23
+ # config.content_security_policy_nonce_directives = %w(script-src)
24
+ #
25
+ # # Report violations without enforcing the policy.
26
+ # # config.content_security_policy_report_only = true
27
+ # 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 filtered from the log file. Use this to limit dissemination of
6
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
7
+ # notations and behaviors.
8
+ Rails.application.config.filter_parameters += [
9
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
10
+ ]
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This is a way to use UUID as a default primary key across application, but it requires that switch schema.rb to structure.sql.
4
+
5
+ # Rails.application.config.generators do |g|
6
+ # g.orm :active_record, primary_key_type: :uuid
7
+ # end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Add new inflection rules using the following format. Inflections
6
+ # are locale specific, and you may define rules for as many different
7
+ # locales as you wish. All of these examples are active by default:
8
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
9
+ # inflect.plural /^(ox)$/i, "\\1en"
10
+ # inflect.singular /^(ox)en/i, "\\1"
11
+ # inflect.irregular "person", "people"
12
+ # inflect.uncountable %w( fish sheep )
13
+ # end
14
+
15
+ # These inflection rules are supported but not enabled by default:
16
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
17
+ # inflect.acronym "RESTful"
18
+ # end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../app/webhooks/test_handler"
4
+
5
+ Munster.configure do |config|
6
+ config.active_handlers = [WebhookTestHandler]
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
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 |f|
7
+ # f.camera :none
8
+ # f.gyroscope :none
9
+ # f.microphone :none
10
+ # f.usb :none
11
+ # f.fullscreen :self
12
+ # f.payment :self, "https://secure.example.com"
13
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than 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
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # "true": "foo"
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Puma can serve each request in a thread from an internal thread pool.
4
+ # The `threads` method setting takes two numbers: a minimum and maximum.
5
+ # Any libraries that use thread pools should be configured to match
6
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
7
+ # and maximum; this matches the default thread size of Active Record.
8
+ #
9
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
10
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
11
+ threads min_threads_count, max_threads_count
12
+
13
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
14
+ # terminating a worker in development environments.
15
+ #
16
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
17
+
18
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
19
+ #
20
+ port ENV.fetch("PORT") { 3000 }
21
+
22
+ # Specifies the `environment` that Puma will run in.
23
+ #
24
+ environment ENV.fetch("RAILS_ENV") { "development" }
25
+
26
+ # Specifies the `pidfile` that Puma will use.
27
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
28
+
29
+ # Specifies the number of `workers` to boot in clustered mode.
30
+ # Workers are forked web server processes. If using threads and workers together
31
+ # the concurrency of the application would be max `threads` * `workers`.
32
+ # Workers do not work on JRuby or Windows (both of which do not support
33
+ # processes).
34
+ #
35
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
36
+
37
+ # Use the `preload_app!` method when specifying a `workers` number.
38
+ # This directive tells Puma to first boot the application and load code
39
+ # before forking the application. This takes advantage of Copy On Write
40
+ # process behavior so workers use less memory.
41
+ #
42
+ # preload_app!
43
+
44
+ # Allow puma to be restarted by `bin/rails restart` command.
45
+ plugin :tmp_restart
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ mount Munster::Engine, at: "/webhooks"
5
+ end
data/example/config.ru ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require_relative "config/environment"
6
+
7
+ run Rails.application
8
+ Rails.application.load_server
@@ -0,0 +1,22 @@
1
+ class CreateMunsterTables < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :received_webhooks do |t|
4
+ t.string :handler_event_id, null: false
5
+ t.string :handler_module_name, null: false
6
+ t.string :status, default: "received", null: false
7
+
8
+ # We don't assume, that we can always parse received body as JSON. Body could be invalid or partly missing,
9
+ # we can argue how we can handle that for different integrations, but we still should be able to save this data
10
+ # if it's required. Hence, we don't use :jsonb, but :binary type column here.
11
+ t.binary :body, null: false
12
+
13
+ t.timestamps
14
+ end
15
+
16
+ # For deduplication at ingress. UNIQUE indices in Postgres are case-sensitive
17
+ # which is what we want, as these are externally-generated IDs
18
+ add_index :received_webhooks, [:handler_module_name, :handler_event_id], unique: true, name: "webhook_dedup_idx"
19
+ # For backfill processing (to know how many skipped etc. payloads we have)
20
+ add_index :received_webhooks, [:status]
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[7.0].define(version: 2024_05_23_125859) do
14
+ create_table "received_webhooks", force: :cascade do |t|
15
+ t.string "handler_event_id", null: false
16
+ t.string "handler_module_name", null: false
17
+ t.string "status", default: "received", null: false
18
+ t.binary "body", null: false
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
+ t.index ["handler_module_name", "handler_event_id"], name: "webhook_dedup_idx", unique: true
22
+ t.index ["status"], name: "index_received_webhooks_on_status"
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file should contain all the record creation needed to seed the database with its default values.
4
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
5
+ #
6
+ # Examples:
7
+ #
8
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
9
+ # Character.create(name: "Luke", movie: movies.first)
File without changes
File without changes
data/example/log/.keep ADDED
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>