jets 1.8.10 → 1.8.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/jets/commands/help/generate.md +1 -1
- data/lib/jets/commands/help/new.md +1 -1
- data/lib/jets/commands/new.rb +1 -1
- data/lib/jets/commands/templates/skeleton/public/index.html.tt +1 -1
- data/lib/jets/controller/rack/adapter.rb +26 -1
- data/lib/jets/controller/rendering/rack_renderer.rb +5 -1
- data/lib/jets/processors/main_processor.rb +4 -2
- data/lib/jets/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: fb3d00ff418ec347dac447658effba631e98a994dd0fcf4104776a97b5fbad58
|
4
|
+
data.tar.gz: 6dfc483a6a998d275689361ed94897cd7fb45d7f65b1c6e5b370697fa7e2f80f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
19
|
+
jets generate scaffold post title:string body:text published:boolean
|
20
20
|
|
21
21
|
To deploy to AWS Lambda:
|
22
22
|
jets deploy
|
data/lib/jets/commands/new.rb
CHANGED
@@ -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
|
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.
|
@@ -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
|
-
|
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
|
-
|
39
|
-
|
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
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.
|
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-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|