hasura_handler 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/hasura_handler/actions_controller.rb +5 -5
- data/app/controllers/hasura_handler/application_controller.rb +4 -0
- data/app/controllers/hasura_handler/events_controller.rb +3 -3
- data/config/routes.rb +2 -2
- data/lib/hasura_handler.rb +1 -1
- data/lib/hasura_handler/action.rb +0 -1
- data/lib/hasura_handler/event.rb +6 -6
- data/lib/hasura_handler/event_handler.rb +0 -2
- data/lib/hasura_handler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38ae7966df4db82ef068c5a743c58cd3d94083c97b5148eb2e18761cff1586f8
|
4
|
+
data.tar.gz: e7cf9a60739d6b26ee14bb8aa469f41908c6818b43fbf570566bc334376917b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6f3f0219bcd1180003b5662aeb53ec7783a6c7a6cc4296754ae82f96e01d038aed2fe0c36be08e360a815d2e04b20499809aa3a7012ef61bac11df2eede4262
|
7
|
+
data.tar.gz: 7567e337ae3eb9ebeb9806a5128c2fa45bba31b7e504d66e5c5bd66cc9e847dde42747aacd4f60e57a5a4359e1264ff41d0ecdbbfd681ddc1b21e352bc5e3d03
|
@@ -2,14 +2,14 @@ require_dependency 'hasura_handler/application_controller'
|
|
2
2
|
|
3
3
|
module HasuraHandler
|
4
4
|
class ActionsController < ApplicationController
|
5
|
-
def
|
6
|
-
unless HasuraHandler::Action.hasura_actions.keys.include?(action_params[
|
5
|
+
def index
|
6
|
+
unless HasuraHandler::Action.hasura_actions.keys.include?(action_params['action']['name'])
|
7
7
|
render json: { error: true, message: 'action name not registered' }, status: 404
|
8
8
|
return
|
9
9
|
end
|
10
10
|
|
11
|
-
klass = HasuraHandler::Action.hasura_actions[action_params[
|
12
|
-
action = klass.new(action_params[
|
11
|
+
klass = HasuraHandler::Action.hasura_actions[action_params['action']['name']]
|
12
|
+
action = klass.new(action_params['session_variables'].to_h, action_params['input'].to_h)
|
13
13
|
action.run
|
14
14
|
|
15
15
|
if action.error_message.present?
|
@@ -20,7 +20,7 @@ module HasuraHandler
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def action_params
|
23
|
-
|
23
|
+
full_params.permit(
|
24
24
|
action: [:name],
|
25
25
|
input: {},
|
26
26
|
session_variables: {}
|
@@ -2,8 +2,8 @@ require_dependency 'hasura_handler/application_controller'
|
|
2
2
|
|
3
3
|
module HasuraHandler
|
4
4
|
class EventsController < ApplicationController
|
5
|
-
def
|
6
|
-
processor = HasuraHandler::EventHandler.new(event_params)
|
5
|
+
def index
|
6
|
+
processor = HasuraHandler::EventHandler.new(event_params.to_h)
|
7
7
|
|
8
8
|
unless processor.event.valid?
|
9
9
|
error_response(processor.event.errors)
|
@@ -32,7 +32,7 @@ module HasuraHandler
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def event_params
|
35
|
-
|
35
|
+
full_params.permit(
|
36
36
|
:id,
|
37
37
|
:created_at,
|
38
38
|
table: [
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
HasuraHandler::Engine.routes.draw do
|
2
2
|
if HasuraHandler.events_enabled
|
3
|
-
post '/events', to: 'events#
|
3
|
+
post '/events', to: 'events#index'
|
4
4
|
end
|
5
5
|
|
6
6
|
if HasuraHandler.actions_enabled
|
7
|
-
post '/actions', to: 'actions#
|
7
|
+
post '/actions', to: 'actions#index'
|
8
8
|
end
|
9
9
|
end
|
data/lib/hasura_handler.rb
CHANGED
@@ -5,7 +5,6 @@ module HasuraHandler
|
|
5
5
|
attr_reader :hasura_action_name
|
6
6
|
|
7
7
|
def action_name(action_name)
|
8
|
-
raise 'run method not defined' unless new(nil, nil).respond_to?(:run)
|
9
8
|
raise 'action_name must be a symbol or string' unless action_name.is_a?(Symbol) || action_name.is_a?(String)
|
10
9
|
raise 'action_name already used' if @@hasura_actions.keys.include?(action_name.to_s)
|
11
10
|
|
data/lib/hasura_handler/event.rb
CHANGED
@@ -10,11 +10,11 @@ module HasuraHandler
|
|
10
10
|
:valid
|
11
11
|
|
12
12
|
def initialize(event)
|
13
|
-
@id = event[
|
14
|
-
@table = event[
|
15
|
-
@trigger = event[
|
16
|
-
@event = event[
|
17
|
-
@created_at = event[
|
13
|
+
@id = event['id']
|
14
|
+
@table = event['table']
|
15
|
+
@trigger = event['trigger']
|
16
|
+
@event = event['event']
|
17
|
+
@created_at = event['created_at']
|
18
18
|
@raw_event = event
|
19
19
|
@errors = {}
|
20
20
|
|
@@ -65,7 +65,7 @@ module HasuraHandler
|
|
65
65
|
return
|
66
66
|
end
|
67
67
|
|
68
|
-
@errors['event.session_variables'] = 'not a hash' unless @event[
|
68
|
+
@errors['event.session_variables'] = 'not a hash' unless @event['session_variables'].is_a?(Hash)
|
69
69
|
string_fields?(@event, 'event', [:op])
|
70
70
|
|
71
71
|
[:new, :old].each do |field|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hasura_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaz Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|