jets 3.0.16 → 3.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/jets.gemspec +1 -1
- data/lib/jets/commands/deploy.rb +7 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +1 -0
- data/lib/jets/controller/base.rb +22 -2
- data/lib/jets/controller/rack/adapter.rb +4 -4
- data/lib/jets/controller/rack/env.rb +6 -4
- data/lib/jets/controller/redirection.rb +14 -4
- data/lib/jets/generator/templates/rails/scaffold_controller/controller.rb +3 -15
- data/lib/jets/job/base.rb +2 -2
- data/lib/jets/middleware/default_stack.rb +1 -1
- data/lib/jets/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549f5889b18b5a6dc74ec29259f874a80a6064291b1598ef92c4fd0cdcdc499b
|
4
|
+
data.tar.gz: 1b6a1b5534296e24729763c26b9c9aeba359412aa13da1fad9912d186c1cbef5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc852f9754df45b1b8098a44de6d8b238554ad6ac8baacc005d7b2ce7a6d0a352ae12e19c6f232e8eef1d51fd1fc3fca2326025eeb4b3794d6b5c769b9748fa5
|
7
|
+
data.tar.gz: 818e6be78492e348119d083bc50ac91a34cf63f1e4a1785e4e1f96250418ba391388b876055b1f4916ef9a5c53dab59a1d10732b1d27d2f14ea7d64989ba7b96
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [3.0.20] - 2021-10-20
|
7
|
+
- [#603](https://github.com/boltops-tools/jets/pull/603) redirect_to: smarter handling of request xhr
|
8
|
+
- [#604](https://github.com/boltops-tools/jets/pull/604) fix redirect_to 301 and keep use default
|
9
|
+
|
10
|
+
## [3.0.19] - 2021-10-20
|
11
|
+
- [#602](https://github.com/boltops-tools/jets/pull/602) pin zeitwerk to 2.4.x in gemfile
|
12
|
+
|
13
|
+
## [3.0.18] - 2021-10-20
|
14
|
+
- [#596](https://github.com/boltops-tools/jets/pull/596) Serialize job data correctly
|
15
|
+
- [#598](https://github.com/boltops-tools/jets/pull/598) fixing issues when mounting
|
16
|
+
- [#599](https://github.com/boltops-tools/jets/pull/599) pin to zeitwerk 2.4.x
|
17
|
+
- [#600](https://github.com/boltops-tools/jets/pull/600) method override also on the lambda function side
|
18
|
+
|
19
|
+
## [3.0.17] - 2021-09-15
|
20
|
+
- [#593](https://github.com/boltops-tools/jets/pull/593) Fix deploy for new projects. Added rescue block back into lib/jets/commands/deploy.rb
|
21
|
+
|
6
22
|
## [3.0.16] - 2021-09-10
|
7
23
|
- [#590](https://github.com/boltops-tools/jets/pull/590) Improve Rate Limit Handling
|
8
24
|
|
data/jets.gemspec
CHANGED
@@ -61,7 +61,7 @@ Gem::Specification.new do |spec|
|
|
61
61
|
spec.add_dependency "shotgun"
|
62
62
|
spec.add_dependency "text-table"
|
63
63
|
spec.add_dependency "thor"
|
64
|
-
spec.add_dependency "zeitwerk"
|
64
|
+
spec.add_dependency "zeitwerk", "~> 2.4.0"
|
65
65
|
|
66
66
|
spec.add_development_dependency "bundler"
|
67
67
|
spec.add_development_dependency "byebug"
|
data/lib/jets/commands/deploy.rb
CHANGED
@@ -104,6 +104,13 @@ module Jets::Commands
|
|
104
104
|
def find_stack(stack_name)
|
105
105
|
resp = cfn.describe_stacks(stack_name: stack_name)
|
106
106
|
resp.stacks.first
|
107
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
108
|
+
# example: Stack with id demo-dev does not exist
|
109
|
+
if e.message =~ /Stack with/ && e.message =~ /does not exist/
|
110
|
+
nil
|
111
|
+
else
|
112
|
+
raise
|
113
|
+
end
|
107
114
|
end
|
108
115
|
|
109
116
|
# All CloudFormation states listed here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
|
data/lib/jets/controller/base.rb
CHANGED
@@ -43,7 +43,7 @@ class Jets::Controller
|
|
43
43
|
# Most of the time, you want process! instead of dispatch!
|
44
44
|
#
|
45
45
|
def process!
|
46
|
-
adapter = Jets::Controller::Rack::Adapter.new(event, context
|
46
|
+
adapter = Jets::Controller::Rack::Adapter.new(event, context)
|
47
47
|
adapter.rack_vars(
|
48
48
|
'jets.controller' => self,
|
49
49
|
'lambda.context' => context,
|
@@ -75,6 +75,8 @@ class Jets::Controller
|
|
75
75
|
# dispatch! is useful for megamode or mounted applications
|
76
76
|
#
|
77
77
|
def dispatch!
|
78
|
+
method_override!
|
79
|
+
|
78
80
|
t1 = Time.now
|
79
81
|
log_start
|
80
82
|
|
@@ -99,12 +101,30 @@ class Jets::Controller
|
|
99
101
|
triplet # status, headers, body
|
100
102
|
end
|
101
103
|
|
104
|
+
# Override @meth when POST with _method=delete
|
105
|
+
# By the time processing reaches dispatch which calls method_override!
|
106
|
+
# The Rack::MethodOverride middleware has overriden env['REQUEST_METHOD'] with DELETE
|
107
|
+
# and set env['rack.methodoverride.original_method']
|
108
|
+
def method_override!
|
109
|
+
env = request.env
|
110
|
+
if env['rack.methodoverride.original_method'] && env['REQUEST_METHOD'] == 'DELETE'
|
111
|
+
@original_meth = @meth
|
112
|
+
@meth = "delete"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def processing_log
|
117
|
+
processing = "Processing #{self.class.name}##{@meth}"
|
118
|
+
processing << " (original method #{@original_meth})" if @original_meth
|
119
|
+
processing
|
120
|
+
end
|
121
|
+
|
102
122
|
# Documented interface method, careful not to rename
|
103
123
|
def log_start
|
104
124
|
# JSON.dump makes logging look pretty in CloudWatch logs because it keeps it on 1 line
|
105
125
|
ip = request.ip
|
106
126
|
Jets.logger.info "Started #{@event['httpMethod']} \"#{@event['path']}\" for #{ip} at #{Time.now}"
|
107
|
-
Jets.logger.info
|
127
|
+
Jets.logger.info processing_log
|
108
128
|
Jets.logger.info " Event: #{event_log}"
|
109
129
|
Jets.logger.info " Parameters: #{JSON.dump(filtered_parameters.to_h)}"
|
110
130
|
end
|
@@ -5,13 +5,13 @@ module Jets::Controller::Rack
|
|
5
5
|
extend Memoist
|
6
6
|
|
7
7
|
# Returns back API Gateway response hash structure
|
8
|
-
def self.process(event, context
|
9
|
-
adapter = new(event, context
|
8
|
+
def self.process(event, context)
|
9
|
+
adapter = new(event, context)
|
10
10
|
adapter.process
|
11
11
|
end
|
12
12
|
|
13
|
-
def initialize(event, context
|
14
|
-
@event, @context
|
13
|
+
def initialize(event, context)
|
14
|
+
@event, @context = event, context
|
15
15
|
end
|
16
16
|
|
17
17
|
# 1. Convert API Gateway event event to Rack env
|
@@ -27,12 +27,12 @@ module Jets::Controller::Rack
|
|
27
27
|
def path_with_base_path
|
28
28
|
resource = @event['resource']
|
29
29
|
pathParameters = @event['pathParameters']
|
30
|
-
|
30
|
+
|
31
31
|
if(!pathParameters.nil? and !resource.nil?)
|
32
32
|
resource = pathParameters.reduce(resource) {|resource, parameter|
|
33
33
|
key, value = parameter
|
34
|
-
|
35
|
-
resource = resource.gsub(key, value)
|
34
|
+
resource = resource.gsub("{#{key}+}", value)
|
35
|
+
resource = resource.gsub("{#{key}}", value)
|
36
36
|
resource
|
37
37
|
}
|
38
38
|
end
|
@@ -64,7 +64,9 @@ module Jets::Controller::Rack
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def content_type
|
67
|
-
|
67
|
+
# Rack (local) uses Content-Type and APIGW (remote) uses content-type
|
68
|
+
# Rack::MethodOverride relys on content-type to detect content type properly.
|
69
|
+
headers['Content-Type'] || headers['content-type'] || Jets::Controller::DEFAULT_CONTENT_TYPE
|
68
70
|
end
|
69
71
|
|
70
72
|
def content_length
|
@@ -10,12 +10,22 @@ class Jets::Controller
|
|
10
10
|
redirect_url = add_stage(url)
|
11
11
|
redirect_url = ensure_protocol(redirect_url)
|
12
12
|
|
13
|
-
|
14
|
-
status: options[:status] || 302,
|
13
|
+
default = {
|
15
14
|
headers: { "Location" => redirect_url },
|
16
|
-
body: "",
|
17
15
|
isBase64Encoded: false,
|
18
|
-
|
16
|
+
}
|
17
|
+
if request.xhr?
|
18
|
+
options[:content_type] = "application/json"
|
19
|
+
options[:status] = 200
|
20
|
+
options[:body] = JSON.dump(success: true, location: redirect_url)
|
21
|
+
else
|
22
|
+
options[:status] = 301
|
23
|
+
options[:body] = ""
|
24
|
+
end
|
25
|
+
Jets.logger.info("redirect_to options #{options}")
|
26
|
+
options = default.merge(options)
|
27
|
+
|
28
|
+
aws_proxy = Rendering::RackRenderer.new(self, options)
|
19
29
|
resp = aws_proxy.render
|
20
30
|
# redirect is a type of rendering
|
21
31
|
@rendered = true
|
@@ -29,11 +29,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
29
29
|
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
30
30
|
|
31
31
|
if @<%= orm_instance.save %>
|
32
|
-
|
33
|
-
render json: {success: true, location: url_for(@<%= singular_table_name %>)}
|
34
|
-
else
|
35
|
-
redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
|
36
|
-
end
|
32
|
+
redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
|
37
33
|
else
|
38
34
|
render :new
|
39
35
|
end
|
@@ -42,11 +38,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
42
38
|
# PUT <%= route_url %>/1
|
43
39
|
def update
|
44
40
|
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
45
|
-
|
46
|
-
render json: {success: true, location: url_for(@<%= singular_table_name %>)}
|
47
|
-
else
|
48
|
-
redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
|
49
|
-
end
|
41
|
+
redirect_to <%= singular_table_name %>_path(@<%= singular_table_name %>)
|
50
42
|
else
|
51
43
|
render :edit
|
52
44
|
end
|
@@ -55,11 +47,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
55
47
|
# DELETE <%= route_url %>/1
|
56
48
|
def delete
|
57
49
|
@<%= orm_instance.destroy %>
|
58
|
-
|
59
|
-
render json: {success: true, location: <%= table_name %>_path}
|
60
|
-
else
|
61
|
-
redirect_to <%= table_name %>_path
|
62
|
-
end
|
50
|
+
redirect_to <%= table_name %>_path
|
63
51
|
end
|
64
52
|
|
65
53
|
private
|
data/lib/jets/job/base.rb
CHANGED
@@ -26,13 +26,13 @@ module Jets::Job
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def perform_now(meth, event={}, context={})
|
29
|
-
new(event, context, meth).send(meth)
|
29
|
+
new(event.try(:to_unsafe_h), context, meth).send(meth)
|
30
30
|
end
|
31
31
|
|
32
32
|
def perform_later(meth, event={}, context={})
|
33
33
|
if on_lambda?
|
34
34
|
function_name = "#{self.to_s.underscore}-#{meth}"
|
35
|
-
call = Jets::Commands::Call.new(function_name, JSON.dump(event), invocation_type: "Event")
|
35
|
+
call = Jets::Commands::Call.new(function_name, JSON.dump(event.try(:to_unsafe_h)), invocation_type: "Event")
|
36
36
|
call.run
|
37
37
|
else
|
38
38
|
puts "INFO: Not on AWS Lambda. In local mode perform_later executes the job with perform_now instead."
|
@@ -13,7 +13,7 @@ module Jets::Middleware
|
|
13
13
|
middleware.use Shotgun::Static
|
14
14
|
middleware.use Rack::Runtime
|
15
15
|
middleware.use Jets::Controller::Middleware::Cors if cors_enabled?
|
16
|
-
middleware.use Rack::MethodOverride # must come before Middleware::Local for multipart post forms to work
|
16
|
+
middleware.use Rack::MethodOverride unless ENV['JETS_RACK_METHOD_OVERRIDE'] == '0' # must come before Middleware::Local for multipart post forms to work
|
17
17
|
middleware.use Jets::Controller::Middleware::Reloader if Jets.config.hot_reload
|
18
18
|
middleware.use Jets::Controller::Middleware::Local # mimics AWS Lambda for local server only
|
19
19
|
middleware.use session_store, session_options
|
data/lib/jets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -490,16 +490,16 @@ dependencies:
|
|
490
490
|
name: zeitwerk
|
491
491
|
requirement: !ruby/object:Gem::Requirement
|
492
492
|
requirements:
|
493
|
-
- - "
|
493
|
+
- - "~>"
|
494
494
|
- !ruby/object:Gem::Version
|
495
|
-
version:
|
495
|
+
version: 2.4.0
|
496
496
|
type: :runtime
|
497
497
|
prerelease: false
|
498
498
|
version_requirements: !ruby/object:Gem::Requirement
|
499
499
|
requirements:
|
500
|
-
- - "
|
500
|
+
- - "~>"
|
501
501
|
- !ruby/object:Gem::Version
|
502
|
-
version:
|
502
|
+
version: 2.4.0
|
503
503
|
- !ruby/object:Gem::Dependency
|
504
504
|
name: bundler
|
505
505
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1095,7 +1095,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1095
1095
|
- !ruby/object:Gem::Version
|
1096
1096
|
version: '0'
|
1097
1097
|
requirements: []
|
1098
|
-
rubygems_version: 3.
|
1098
|
+
rubygems_version: 3.1.6
|
1099
1099
|
signing_key:
|
1100
1100
|
specification_version: 4
|
1101
1101
|
summary: Ruby Serverless Framework
|