jets 1.8.10 → 1.8.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22ddc04092ba46aff21f3995f5c250a120c997fa5c91c60afe7c7922152ea405
4
- data.tar.gz: d5c2976db58b411024a26a24b4016b91290e55bec4aaf711be89a5e62e23c590
3
+ metadata.gz: fb3d00ff418ec347dac447658effba631e98a994dd0fcf4104776a97b5fbad58
4
+ data.tar.gz: 6dfc483a6a998d275689361ed94897cd7fb45d7f65b1c6e5b370697fa7e2f80f
5
5
  SHA512:
6
- metadata.gz: 697201cc4e1af7c8c7449f7d020853d519293ccae20892ad98e13a99990e4c5f57d695699c2b0587ea670f9831bec365a9c52827e821ad7070e493f6fa88dd08
7
- data.tar.gz: b7cc5028f62577e4a754892c427c5c0730cbdb05a0b48b3df31053addf70626c9ee1bf860f48e53e352def4e9c994baa94c0626990d9155995377b5048ec0747
6
+ metadata.gz: ab31c4838c3c9d435e471610099d3f9e2b9ba1cbef514ab86664ae259b71faf9ecbf60446c671e18909214a74584f6ab839be79ffea6b8fd9a3d1c2b0293c50c
7
+ data.tar.gz: 5cb30b77d29e3ba878e0f2acaaac0083d5376e6ff9efc3fbedf23386046ca03667198d19de34a4edb1d91fcbfd782b2607a7fd13a45ff6759325c4b99a9d0a0f
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
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
+ ## [1.8.11]
7
+ - #242 adjust resp when request coming from elb
8
+ - update jets generate scaffold post casing
9
+
6
10
  ## [1.8.10]
7
11
  - #208 add jets degenerate as opposite of generator
8
12
  - #219 fix circleci usage, remove CIRCLECI env
@@ -2,7 +2,7 @@ This piggy backs off of the [rails scaffold generator](https://guides.rubyonrail
2
2
 
3
3
  ## Example
4
4
 
5
- $ jets generate scaffold Post title:string body:text published:boolean
5
+ $ jets generate scaffold post title:string body:text published:boolean
6
6
  invoke active_record
7
7
  create db/migrate/20180817052529_create_posts.rb
8
8
  create app/models/post.rb
@@ -16,7 +16,7 @@
16
16
  jets server # localhost:8888 should have the Jets welcome page
17
17
 
18
18
  Scaffold example:
19
- jets generate scaffold Post title:string body:text published:boolean
19
+ jets generate scaffold post title:string body:text published:boolean
20
20
 
21
21
  To deploy to AWS Lambda:
22
22
  jets deploy
@@ -133,7 +133,7 @@ JS
133
133
  jets server # localhost:8888 should have the Jets welcome page
134
134
 
135
135
  Scaffold example:
136
- jets generate scaffold Post title:string body:text published:boolean
136
+ jets generate scaffold post title:string body:text published:boolean
137
137
  jets db:create db:migrate
138
138
 
139
139
  To deploy to AWS Lambda, edit your .env.development.remote and add a DATABASE_URL endpoint.
@@ -73,7 +73,7 @@
73
73
  To get started:
74
74
  </p>
75
75
  <div class="code"><pre><code>
76
- $ jets generate scaffold Post title:string
76
+ $ jets generate scaffold post title:string
77
77
  $ jets db:create db:migrate
78
78
  $ jets server
79
79
  $ open http://localhost:8888/posts
@@ -33,12 +33,37 @@ module Jets::Controller::Rack
33
33
  base64 = headers["x-jets-base64"] == 'yes'
34
34
  body = body.respond_to?(:read) ? body.read : body
35
35
  body = Base64.encode64(body) if base64
36
- {
36
+
37
+ resp = {
37
38
  "statusCode" => status,
38
39
  "headers" => headers,
39
40
  "body" => body,
40
41
  "isBase64Encoded" => base64,
41
42
  }
43
+ adjust_for_elb(resp)
44
+ resp
45
+ end
46
+
47
+ # Note: ELB is not officially support. This is just in case users wish to manually
48
+ # connect ELBs to the functions created by Jets.
49
+ def adjust_for_elb(resp)
50
+ return resp unless from_elb?
51
+
52
+ # ELB requires statusCode to be an Integer whereas API Gateway requires statusCode to be a String
53
+ status = resp["statusCode"] = resp["statusCode"].to_i
54
+
55
+ # ELB also requires statusDescription attribute
56
+ status_desc = Rack::Utils::HTTP_STATUS_CODES[status]
57
+ status_desc = status_desc.nil? ? status.to_s : "#{status} #{status_desc}"
58
+ resp["statusDescription"] = status_desc
59
+
60
+ resp
61
+ end
62
+
63
+ def from_elb?
64
+ # NOTE: @event["requestContext"]["elb"] is set when the request is coming from an elb
65
+ # Can set JETS_ELB=1 for local testing
66
+ @event["requestContext"] && @event["requestContext"]["elb"] || ENV['JETS_ELB']
42
67
  end
43
68
 
44
69
  # Called from Jets::Controller::Base.process. Example:
@@ -165,7 +165,11 @@ module Jets::Controller::Rendering
165
165
  else
166
166
  code
167
167
  end
168
- (status_code || 200).to_s # API Gateway requires a string but rack is okay with either
168
+
169
+ # API Gateway requires status to be String but local rack is okay with either
170
+ # Note, ELB though requires status to be an Integer. We'll later in rack/adapter.rb
171
+ # adjust status to an Integer if request is coming from an ELB.
172
+ (status_code || 200).to_s
169
173
  end
170
174
 
171
175
  def set_content_type!(status, headers)
@@ -35,8 +35,10 @@ class Jets::Processors::MainProcessor
35
35
  Jets.increase_call_count
36
36
 
37
37
  if result.is_a?(Hash) && result["headers"]
38
- result["headers"]["x-jets-call-count"] = Jets.call_count
39
- result["headers"]["x-jets-prewarm-count"] = Jets.prewarm_count
38
+ # API Gateway is okay with the header values as Integers but
39
+ # ELBs are more strict about this and require the header values to be Strings
40
+ result["headers"]["x-jets-call-count"] = Jets.call_count.to_s
41
+ result["headers"]["x-jets-prewarm-count"] = Jets.prewarm_count.to_s
40
42
  end
41
43
 
42
44
  result
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.8.10"
2
+ VERSION = "1.8.11"
3
3
  end
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: 1.8.10
4
+ version: 1.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-27 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer