webhooks-rails 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +20 -0
- data/app/assets/config/webhooks_manifest.js +1 -0
- data/app/assets/stylesheets/webhooks/application.css +15 -0
- data/app/controllers/webhooks/application_controller.rb +6 -0
- data/app/controllers/webhooks/attempts_controller.rb +25 -0
- data/app/controllers/webhooks/endpoints_controller.rb +65 -0
- data/app/controllers/webhooks/events_controller.rb +37 -0
- data/app/helpers/webhooks/application_helper.rb +6 -0
- data/app/jobs/webhooks/application_job.rb +6 -0
- data/app/jobs/webhooks/deliver_job.rb +11 -0
- data/app/mailers/webhooks/application_mailer.rb +8 -0
- data/app/models/webhooks/application_record.rb +7 -0
- data/app/models/webhooks/attempt.rb +71 -0
- data/app/models/webhooks/endpoint.rb +74 -0
- data/app/models/webhooks/event.rb +50 -0
- data/app/models/webhooks/event_serializer.rb +30 -0
- data/app/models/webhooks/request.rb +37 -0
- data/app/models/webhooks/response.rb +29 -0
- data/app/views/layouts/webhooks/application.html.erb +29 -0
- data/app/views/webhooks/attempts/_attempt.html.erb +32 -0
- data/app/views/webhooks/attempts/show.html.erb +33 -0
- data/app/views/webhooks/endpoints/_endpoint.html.erb +31 -0
- data/app/views/webhooks/endpoints/_form.html.erb +42 -0
- data/app/views/webhooks/endpoints/edit.html.erb +16 -0
- data/app/views/webhooks/endpoints/index.html.erb +41 -0
- data/app/views/webhooks/endpoints/new.html.erb +16 -0
- data/app/views/webhooks/endpoints/show.html.erb +102 -0
- data/app/views/webhooks/events/_event.html.erb +11 -0
- data/app/views/webhooks/events/index.html.erb +38 -0
- data/app/views/webhooks/events/new.html.erb +35 -0
- data/app/views/webhooks/events/show.html.erb +49 -0
- data/app/views/webhooks/requests/_request.html.erb +47 -0
- data/app/views/webhooks/responses/_response.html.erb +55 -0
- data/app/views/webhooks/shared/_navigation.html.erb +100 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20210518022959_create_webhooks_endpoints.rb +17 -0
- data/db/migrate/20210518043350_create_webhooks_events.rb +12 -0
- data/db/migrate/20210518050123_create_webhooks_attempts.rb +36 -0
- data/db/migrate/20210518054916_create_webhooks_requests.rb +14 -0
- data/db/migrate/20210518060614_create_webhooks_responses.rb +15 -0
- data/lib/tasks/webhooks_tasks.rake +5 -0
- data/lib/webhooks-rails.rb +3 -0
- data/lib/webhooks.rb +21 -0
- data/lib/webhooks/engine.rb +31 -0
- data/lib/webhooks/version.rb +5 -0
- metadata +183 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateWebhooksResponses < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
create_table :webhooks_responses do |t|
|
6
|
+
t.belongs_to :webhooks_request, null: false, foreign_key: true, index: { unique: true }
|
7
|
+
|
8
|
+
t.integer :status_code, null: false
|
9
|
+
t.json :headers, null: false
|
10
|
+
t.text :body, null: true
|
11
|
+
|
12
|
+
t.datetime :created_at, null: false, precision: 6
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/webhooks.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'webhooks/version'
|
4
|
+
require 'webhooks/engine'
|
5
|
+
require 'faraday'
|
6
|
+
require 'faraday_middleware'
|
7
|
+
|
8
|
+
module Webhooks
|
9
|
+
def self.client
|
10
|
+
@client ||= Faraday.new do |conn|
|
11
|
+
conn.headers[:user_agent] = Rails.application.config.webhooks.user_agent
|
12
|
+
conn.headers[:content_type] = 'application/json'
|
13
|
+
conn.headers[:accept] = 'application/json'
|
14
|
+
|
15
|
+
conn.request :json
|
16
|
+
|
17
|
+
conn.options.timeout = Rails.application.config.webhooks.requests.read_timeout
|
18
|
+
conn.options.open_timeout = Rails.application.config.webhooks.requests.open_timeout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Webhooks
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace Webhooks
|
6
|
+
|
7
|
+
engine_name 'webhooks'
|
8
|
+
|
9
|
+
config.webhooks = ActiveSupport::OrderedOptions.new
|
10
|
+
config.webhooks.events = ActiveSupport::OrderedOptions.new
|
11
|
+
|
12
|
+
# If there are no webhook endpoints subscribing to an event that was just
|
13
|
+
# published, decide if we want to store the event or not. Storing the event
|
14
|
+
# will not trigger any webhook attempts at that time or in the future.
|
15
|
+
config.webhooks.events.create_without_subscribed_endpoint = false
|
16
|
+
config.webhooks.events.types = []
|
17
|
+
config.webhooks.user_agent = "webhooks-rails/v#{Webhooks::VERSION}"
|
18
|
+
config.webhooks.endpoints = ActiveSupport::OrderedOptions.new
|
19
|
+
config.webhooks.endpoints.valid_schemas = %w[https]
|
20
|
+
|
21
|
+
# Configuration for the webhook attempts
|
22
|
+
config.webhooks.attempts = ActiveSupport::OrderedOptions.new
|
23
|
+
config.webhooks.attempts.limit = 3
|
24
|
+
|
25
|
+
# Configuration for the actual webhook requests
|
26
|
+
config.webhooks.requests = ActiveSupport::OrderedOptions.new
|
27
|
+
config.webhooks.requests.read_timeout = 30
|
28
|
+
config.webhooks.requests.open_timeout = 10
|
29
|
+
config.webhooks.requests.header = 'X-Webhooks-Signature'
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webhooks-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Garrett Bjerkhoel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.1.3
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 6.1.3.1
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 6.1.3
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 6.1.3.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.12.1
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.12.1
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop-performance
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.10.2
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.10.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubocop-rails
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.9.1
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.9.1
|
103
|
+
description: A Rails engine to configure and deliver webhooks.
|
104
|
+
email:
|
105
|
+
- garrett@cased.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- MIT-LICENSE
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- app/assets/config/webhooks_manifest.js
|
114
|
+
- app/assets/stylesheets/webhooks/application.css
|
115
|
+
- app/controllers/webhooks/application_controller.rb
|
116
|
+
- app/controllers/webhooks/attempts_controller.rb
|
117
|
+
- app/controllers/webhooks/endpoints_controller.rb
|
118
|
+
- app/controllers/webhooks/events_controller.rb
|
119
|
+
- app/helpers/webhooks/application_helper.rb
|
120
|
+
- app/jobs/webhooks/application_job.rb
|
121
|
+
- app/jobs/webhooks/deliver_job.rb
|
122
|
+
- app/mailers/webhooks/application_mailer.rb
|
123
|
+
- app/models/webhooks/application_record.rb
|
124
|
+
- app/models/webhooks/attempt.rb
|
125
|
+
- app/models/webhooks/endpoint.rb
|
126
|
+
- app/models/webhooks/event.rb
|
127
|
+
- app/models/webhooks/event_serializer.rb
|
128
|
+
- app/models/webhooks/request.rb
|
129
|
+
- app/models/webhooks/response.rb
|
130
|
+
- app/views/layouts/webhooks/application.html.erb
|
131
|
+
- app/views/webhooks/attempts/_attempt.html.erb
|
132
|
+
- app/views/webhooks/attempts/show.html.erb
|
133
|
+
- app/views/webhooks/endpoints/_endpoint.html.erb
|
134
|
+
- app/views/webhooks/endpoints/_form.html.erb
|
135
|
+
- app/views/webhooks/endpoints/edit.html.erb
|
136
|
+
- app/views/webhooks/endpoints/index.html.erb
|
137
|
+
- app/views/webhooks/endpoints/new.html.erb
|
138
|
+
- app/views/webhooks/endpoints/show.html.erb
|
139
|
+
- app/views/webhooks/events/_event.html.erb
|
140
|
+
- app/views/webhooks/events/index.html.erb
|
141
|
+
- app/views/webhooks/events/new.html.erb
|
142
|
+
- app/views/webhooks/events/show.html.erb
|
143
|
+
- app/views/webhooks/requests/_request.html.erb
|
144
|
+
- app/views/webhooks/responses/_response.html.erb
|
145
|
+
- app/views/webhooks/shared/_navigation.html.erb
|
146
|
+
- config/routes.rb
|
147
|
+
- db/migrate/20210518022959_create_webhooks_endpoints.rb
|
148
|
+
- db/migrate/20210518043350_create_webhooks_events.rb
|
149
|
+
- db/migrate/20210518050123_create_webhooks_attempts.rb
|
150
|
+
- db/migrate/20210518054916_create_webhooks_requests.rb
|
151
|
+
- db/migrate/20210518060614_create_webhooks_responses.rb
|
152
|
+
- lib/tasks/webhooks_tasks.rake
|
153
|
+
- lib/webhooks-rails.rb
|
154
|
+
- lib/webhooks.rb
|
155
|
+
- lib/webhooks/engine.rb
|
156
|
+
- lib/webhooks/version.rb
|
157
|
+
homepage: https://github.com/cased/webhooks-rails
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata:
|
161
|
+
homepage_uri: https://github.com/cased/webhooks-rails
|
162
|
+
source_code_uri: https://github.com/cased/webhooks-rails
|
163
|
+
changelog_uri: https://github.com/cased/webhooks-rails/releases
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 2.4.0
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubygems_version: 3.0.3
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: A Rails engine to configure and deliver webhooks.
|
183
|
+
test_files: []
|