jets 2.3.12 → 2.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/docs/bin/git_setup.sh +0 -9
- data/.ruby-version +1 -1
- data/CHANGELOG.md +41 -0
- data/Gemfile +1 -1
- data/jets.gemspec +0 -1
- data/lib/jets.rb +2 -0
- data/lib/jets/application/defaults.rb +1 -0
- data/lib/jets/booter.rb +1 -1
- data/lib/jets/builders/code_builder.rb +14 -5
- data/lib/jets/builders/gem_replacer.rb +3 -1
- data/lib/jets/builders/ruby_packager.rb +1 -1
- data/lib/jets/commands/build.rb +1 -0
- data/lib/jets/commands/call.rb +1 -1
- data/lib/jets/commands/call/base_guesser.rb +4 -2
- data/lib/jets/commands/gems.rb +1 -1
- data/lib/jets/commands/import/base.rb +1 -1
- data/lib/jets/commands/main.rb +1 -1
- data/lib/jets/commands/new.rb +1 -1
- data/lib/jets/commands/rake_tasks.rb +1 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +2 -2
- data/lib/jets/commands/templates/webpacker/app/javascript/packs/application.js.tt +9 -1
- data/lib/jets/controller/authorization.rb +10 -1
- data/lib/jets/controller/base.rb +17 -4
- data/lib/jets/controller/parameters_filter.rb +29 -0
- data/lib/jets/controller/params.rb +8 -0
- data/lib/jets/core_ext/bundler.rb +7 -0
- data/lib/jets/dotenv.rb +5 -5
- data/lib/jets/internal/turbines/jets/mailer.rb +1 -0
- data/lib/jets/job/base.rb +1 -1
- data/lib/jets/rack_server.rb +1 -1
- data/lib/jets/resource.rb +4 -4
- data/lib/jets/resource/api_gateway/method.rb +3 -1
- data/lib/jets/resource/api_gateway/method/authorization.rb +9 -0
- data/lib/jets/resource/api_gateway/resource.rb +2 -2
- data/lib/jets/resource/lambda/function.rb +3 -3
- data/lib/jets/router.rb +10 -10
- data/lib/jets/router/route/authorizer.rb +4 -0
- data/lib/jets/turbo/rails.rb +1 -1
- data/lib/jets/turbo/templates/config/database.yml +4 -0
- data/lib/jets/version.rb +1 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 570f01c2fe2cff82700a1c8110b340a6897381d61fa5248f118b785fe399cefe
|
4
|
+
data.tar.gz: 64ad72c3d50974e7e816e5647dbcd3f5e26277144ab409b867e7f7ccc58e166e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c4489b8c063d2a3e94f63b9ebb0fda617a31f41bc92dcd77a32755307fef81930ba1359a3364f13baf8a3ea746234019343b7621bdf2ff27c6b86076fa473e
|
7
|
+
data.tar.gz: 76bf5d77ab7f8b3064174aea1baea7eac92a787d217fb8a91c431132da9fba95ef342a6f8f145f2174c74cb6f4a914c5ba74ce8a6c06c5984528fdee0ce86c24
|
data/.cody/docs/bin/git_setup.sh
CHANGED
@@ -10,12 +10,3 @@
|
|
10
10
|
git config --global user.email "tongueroo@gmail.com"
|
11
11
|
git config --global user.name "Tung Nguyen"
|
12
12
|
|
13
|
-
set +u # cb start will not have CODEBUILD_WEBHOOK_TRIGGER set
|
14
|
-
if [ -n "$CODEBUILD_WEBHOOK_TRIGGER" ]; then # git push
|
15
|
-
BRANCH=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed "s/.*\///")
|
16
|
-
elif [ -n "$CODEBUILD_SOURCE_VERSION" ]; then # cb start
|
17
|
-
BRANCH=$CODEBUILD_SOURCE_VERSION # contains the actual branch
|
18
|
-
else
|
19
|
-
BRANCH=UNKNOWN-BRANCH
|
20
|
-
fi
|
21
|
-
git checkout $BRANCH
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.7
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,47 @@
|
|
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
|
+
## [2.3.17]
|
7
|
+
- #472 Docs: Update cors-support.md
|
8
|
+
- #475 Docs: Update activerecord.md to include db:create step
|
9
|
+
- #476 Docs: Update authorizer-cognito.md
|
10
|
+
- #482 Docs: Fixed description for "jetpacker" gem in Gemfile
|
11
|
+
- #483 Docs: controllers Fix minor typo
|
12
|
+
- #489 Docs: call typo
|
13
|
+
- #490 Docs: authorizers typo
|
14
|
+
- #504 Docs: tutorial series
|
15
|
+
- #505 Docs: display more tutorial articles
|
16
|
+
- #509 Docs: Update lamdba permissions for minimal-iam-policy doc
|
17
|
+
- #512 Bug fix: fix on_lambda? check allow testing #512
|
18
|
+
|
19
|
+
## [2.3.16]
|
20
|
+
- #466 fix application_config typo
|
21
|
+
- #467 Handle forbidden error from s3
|
22
|
+
- #468 authorization_scopes
|
23
|
+
- #469 Fixed typo from STMP to SMTP
|
24
|
+
- #470 remove json dependency
|
25
|
+
- #471 use `Bundler.with_unbundled_env` remove bundler deprecation
|
26
|
+
|
27
|
+
## [2.3.15]
|
28
|
+
- #461 fix guesser lookup for long function names
|
29
|
+
|
30
|
+
## [2.3.14]
|
31
|
+
- #432 filtered_parameters support
|
32
|
+
- #447 improve nested routes support. order routes so that nested resources always work
|
33
|
+
- #451 Fix Jets turbo DB encoding
|
34
|
+
- #452 Print Cfn templates location after build
|
35
|
+
- #458 update webpacker fork with jetpacker gem
|
36
|
+
- #459 fix afterburner mode
|
37
|
+
|
38
|
+
## [2.3.13]
|
39
|
+
- #430 Remove out-of-date note about FIFO Queue
|
40
|
+
- #433 Fixed ApiResources with long names not included in the main CloudFormation template
|
41
|
+
- #435 fix typo SMTP
|
42
|
+
- #437 Ignore *.local files when JETS_ENV_REMOTE=1
|
43
|
+
- #438 Forcing sort of initializers
|
44
|
+
- #446 temp fix for actionmailer turbine initializer
|
45
|
+
- update to ruby 2.5.7
|
46
|
+
|
6
47
|
## [2.3.12]
|
7
48
|
- #421 use underscore for database name in database.yml
|
8
49
|
- #422 url_for: allow any activemodel compatiable object to work
|
data/Gemfile
CHANGED
data/jets.gemspec
CHANGED
@@ -50,7 +50,6 @@ Gem::Specification.new do |spec|
|
|
50
50
|
spec.add_dependency "hashie"
|
51
51
|
spec.add_dependency "jets-gems"
|
52
52
|
spec.add_dependency "jets-html-sanitizer"
|
53
|
-
spec.add_dependency "json"
|
54
53
|
spec.add_dependency "kramdown"
|
55
54
|
spec.add_dependency "memoist"
|
56
55
|
spec.add_dependency "mimemagic"
|
data/lib/jets.rb
CHANGED
@@ -18,6 +18,8 @@ $:.unshift("#{gem_root}/lib")
|
|
18
18
|
$:.unshift("#{gem_root}/vendor/cfn-status/lib")
|
19
19
|
require "cfn_status"
|
20
20
|
|
21
|
+
require "jets/core_ext/bundler"
|
22
|
+
|
21
23
|
require "jets/autoloaders"
|
22
24
|
Jets::Autoloaders.log! if ENV["JETS_AUTOLOAD_LOG"]
|
23
25
|
Jets::Autoloaders.once.setup
|
@@ -149,6 +149,7 @@ class Jets::Application
|
|
149
149
|
|
150
150
|
config.controllers = ActiveSupport::OrderedOptions.new
|
151
151
|
config.controllers.default_protect_from_forgery = nil
|
152
|
+
config.controllers.filtered_parameters = []
|
152
153
|
|
153
154
|
config.deploy = ActiveSupport::OrderedOptions.new
|
154
155
|
config.deploy.stagger = ActiveSupport::OrderedOptions.new
|
data/lib/jets/booter.rb
CHANGED
@@ -82,7 +82,7 @@ module Jets::Builders
|
|
82
82
|
begin
|
83
83
|
s3.head_object(bucket: s3_bucket, key: s3_key)
|
84
84
|
true
|
85
|
-
rescue Aws::S3::Errors::NotFound
|
85
|
+
rescue Aws::S3::Errors::NotFound, Aws::S3::Errors::Forbidden
|
86
86
|
false
|
87
87
|
end
|
88
88
|
end
|
@@ -99,8 +99,17 @@ module Jets::Builders
|
|
99
99
|
|
100
100
|
# Code prep and zipping
|
101
101
|
check_code_size!
|
102
|
-
generate_shims
|
103
|
-
|
102
|
+
calculate_md5s # must be called before create_zip_files and generate_shims because checksums need to be populated
|
103
|
+
# generate_shims and create_zip_files use checksums
|
104
|
+
#
|
105
|
+
# Notes:
|
106
|
+
#
|
107
|
+
# Had moved calculate_md5s to fix a what thought was a subtle issue https://github.com/tongueroo/jets/pull/424
|
108
|
+
# But am unsure about that the fix now. This essentially reverts that issue.
|
109
|
+
#
|
110
|
+
# Fix in https://github.com/tongueroo/jets/pull/459
|
111
|
+
#
|
112
|
+
generate_shims # the generated handlers/data.yml has rack_zip key
|
104
113
|
create_zip_files
|
105
114
|
end
|
106
115
|
|
@@ -211,7 +220,7 @@ module Jets::Builders
|
|
211
220
|
# Checking this way because when using jets standalone for Afterburner mode we don't want to run into
|
212
221
|
# bundler gem collisions. TODO: figure out the a better way to handle the collisions.
|
213
222
|
lines = IO.readlines("#{Jets.root}/Gemfile")
|
214
|
-
lines.detect { |l| l =~ /webpacker/ }
|
223
|
+
lines.detect { |l| l =~ /webpacker/ || l =~ /jetpacker/ }
|
215
224
|
end
|
216
225
|
|
217
226
|
# This happens in the current app directory not the tmp code for simplicity
|
@@ -226,7 +235,7 @@ module Jets::Builders
|
|
226
235
|
|
227
236
|
# Need to capture JETS_ROOT since can be changed by Turbo mode
|
228
237
|
jets_root = Jets.root
|
229
|
-
Bundler.
|
238
|
+
Bundler.with_unbundled_env do
|
230
239
|
# Switch gemfile for Afterburner mode
|
231
240
|
gemfile = ENV['BUNDLE_GEMFILE']
|
232
241
|
ENV['BUNDLE_GEMFILE'] = "#{jets_root}/rack/Gemfile"
|
@@ -6,7 +6,9 @@ module Jets::Builders
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def run
|
9
|
-
|
9
|
+
# use_gemspec to resolve http-parser gem issue
|
10
|
+
use_gemspec = !Jets::Turbo.afterburner? # gemspec approach breaks afterburner mode
|
11
|
+
check = Jets::Gems::Check.new(use_gemspec: use_gemspec)
|
10
12
|
if Jets.config.lambda.layers.empty?
|
11
13
|
found_gems = check.run! # exits early if missing gems found
|
12
14
|
else
|
@@ -59,7 +59,7 @@ module Jets::Builders
|
|
59
59
|
|
60
60
|
FileUtils.rm_rf("#{cache_area}/.bundle")
|
61
61
|
require "bundler" # dynamically require bundler so user can use any bundler
|
62
|
-
Bundler.
|
62
|
+
Bundler.with_unbundled_env do
|
63
63
|
sh(
|
64
64
|
"cd #{cache_area} && " \
|
65
65
|
"env bundle install --path #{cache_area}/vendor/gems --without development test"
|
data/lib/jets/commands/build.rb
CHANGED
data/lib/jets/commands/call.rb
CHANGED
@@ -140,7 +140,7 @@ class Jets::Commands::Call
|
|
140
140
|
puts "Pro tip: The Lambda Console Link to the #{function_name} function has been added to your clipboard." unless @options[:mute]
|
141
141
|
end
|
142
142
|
|
143
|
-
# TODO: Hook client_context up and
|
143
|
+
# TODO: Hook client_context up and make sure it works. Think I've figure out how to sign client_context below.
|
144
144
|
# Client context must be a valid Base64-encoded JSON object
|
145
145
|
# Example: http://docs.aws.amazon.com/mobileanalytics/latest/ug/PutEvents.html
|
146
146
|
def client_context
|
@@ -36,9 +36,11 @@ class Jets::Commands::Call
|
|
36
36
|
def generated_function_name(function_name)
|
37
37
|
if function_name.size > Jets::MAX_FUNCTION_NAME_SIZE # name generated by CloudFormation
|
38
38
|
logical_id = @class_name.gsub('::','')
|
39
|
-
app_stack_arn = lookup(parent_stack[:outputs], logical_id)
|
40
39
|
|
41
|
-
|
40
|
+
parent_resources = stack_resources(parent_stack.stack_id)
|
41
|
+
app_stack = parent_resources.find { |s| s.logical_resource_id == logical_id }
|
42
|
+
|
43
|
+
resources = stack_resources(app_stack.physical_resource_id)
|
42
44
|
resource = resources.find { |r| r.logical_resource_id == method_name.camelize + "LambdaFunction" } # method_name only contains the method
|
43
45
|
resource.physical_resource_id # actual function name
|
44
46
|
else
|
data/lib/jets/commands/gems.rb
CHANGED
@@ -3,7 +3,7 @@ module Jets::Commands
|
|
3
3
|
desc "check", "Check if pre-built Lambda gems are available from the sources"
|
4
4
|
long_desc Help.text("gems:check")
|
5
5
|
def check
|
6
|
-
check = Jets::Gems::Check.new
|
6
|
+
check = Jets::Gems::Check.new
|
7
7
|
check.run! # exits early if missing gems found
|
8
8
|
# If reach here, means all gems are ok.
|
9
9
|
puts "Congrats! All gems are available in as pre-built Lambda gems 👍"
|
data/lib/jets/commands/main.rb
CHANGED
@@ -43,7 +43,7 @@ module Jets::Commands
|
|
43
43
|
puts Jets::Booter.message
|
44
44
|
Jets::Booter.check_config_ru!
|
45
45
|
Jets::RackServer.start(options) unless ENV['JETS_RACK'] == '0' # rack server runs in background by default
|
46
|
-
Bundler.
|
46
|
+
Bundler.with_unbundled_env do
|
47
47
|
system(command)
|
48
48
|
end
|
49
49
|
end
|
data/lib/jets/commands/new.rb
CHANGED
@@ -27,6 +27,7 @@ class Jets::Commands::RakeTasks
|
|
27
27
|
def load_webpacker_tasks
|
28
28
|
begin
|
29
29
|
require "webpacker"
|
30
|
+
require "webpacker/rake_tasks"
|
30
31
|
rescue LoadError
|
31
32
|
# puts "WARN: unable to load gem. #{$!}. Running with 'bundle exec' might fix this warning."
|
32
33
|
# Happens whne user calls jets help outside the jets project folder.
|
@@ -3,8 +3,8 @@ source "https://rubygems.org"
|
|
3
3
|
gem "jets"
|
4
4
|
|
5
5
|
<% if @webpacker -%>
|
6
|
-
# Include
|
7
|
-
gem "
|
6
|
+
# Include jetpacker if you are building html pages
|
7
|
+
gem "jetpacker"
|
8
8
|
<% end -%>
|
9
9
|
<% if @database == 'postgresql' %>
|
10
10
|
# Include pg gem if you are using ActiveRecord, remove next line
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* eslint no-console:0 */
|
2
|
-
// This file is automatically compiled by Webpack
|
2
|
+
// This file is automatically compiled by Webpack, along with any other files
|
3
3
|
// present in this directory. You're encouraged to place your actual application logic in
|
4
4
|
// a relevant structure within app/javascript and only use these pack files to reference
|
5
5
|
// that code so it'll be compiled.
|
@@ -7,6 +7,14 @@
|
|
7
7
|
// To reference this file, add <%%= javascript_pack_tag 'application' %> to the appropriate
|
8
8
|
// layout file, like app/views/layouts/application.html.erb
|
9
9
|
|
10
|
+
|
11
|
+
// Uncomment to copy all static images under ../images to the output folder and reference
|
12
|
+
// them with the image_pack_tag helper in views (e.g <%%= image_pack_tag 'rails.png' %>)
|
13
|
+
// or the `imagePath` JavaScript helper below.
|
14
|
+
//
|
15
|
+
// const images = require.context('../images', true)
|
16
|
+
// const imagePath = (name) => images(name, true)
|
17
|
+
|
10
18
|
<% if @bootstrap -%>
|
11
19
|
import 'bootstrap/dist/js/bootstrap';
|
12
20
|
<% end -%>
|
@@ -6,7 +6,8 @@ class Jets::Controller
|
|
6
6
|
class_attribute :auth_type,
|
7
7
|
:auth_to,
|
8
8
|
:auth_options, # for only and except filters
|
9
|
-
:api_key_needed
|
9
|
+
:api_key_needed,
|
10
|
+
:authorization_scopes_value
|
10
11
|
end
|
11
12
|
|
12
13
|
class_methods do
|
@@ -31,6 +32,14 @@ class Jets::Controller
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
def authorization_scopes(value=nil)
|
36
|
+
if !value.nil?
|
37
|
+
self.authorization_scopes_value = value
|
38
|
+
else
|
39
|
+
self.authorization_scopes_value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
34
43
|
def authorizer_metadata
|
35
44
|
Jets::Router::Route::Authorizer.metadata(auth_to)
|
36
45
|
end
|
data/lib/jets/controller/base.rb
CHANGED
@@ -100,14 +100,27 @@ class Jets::Controller
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def log_info_start
|
103
|
-
display_event = @event.dup
|
104
|
-
display_event['body'] = '[BASE64_ENCODED]' if @event['isBase64Encoded']
|
105
103
|
# JSON.dump makes logging look pretty in CloudWatch logs because it keeps it on 1 line
|
104
|
+
|
106
105
|
ip = request.ip
|
107
106
|
Jets.logger.info "Started #{@event['httpMethod']} \"#{@event['path']}\" for #{ip} at #{Time.now}"
|
108
107
|
Jets.logger.info "Processing #{self.class.name}##{@meth}"
|
109
|
-
Jets.logger.info " Event: #{
|
110
|
-
Jets.logger.info " Parameters: #{JSON.dump(
|
108
|
+
Jets.logger.info " Event: #{event_log}"
|
109
|
+
Jets.logger.info " Parameters: #{JSON.dump(filtered_parameters.to_h)}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def event_log
|
113
|
+
display_event = @event.dup
|
114
|
+
|
115
|
+
if @event['isBase64Encoded']
|
116
|
+
display_event['body'] = '[BASE64_ENCODED]'
|
117
|
+
else
|
118
|
+
display_event['body'] = parameter_filter.filter_json(display_event['body'])
|
119
|
+
end
|
120
|
+
|
121
|
+
display_event["queryStringParameters"] = parameter_filter.filter(display_event['queryStringParameters'])
|
122
|
+
display_event["pathParameters"] = parameter_filter.filter(display_event['pathParameters'])
|
123
|
+
json_dump(display_event)
|
111
124
|
end
|
112
125
|
|
113
126
|
# Handles binary data safely
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "active_support/parameter_filter"
|
2
|
+
|
3
|
+
class Jets::Controller
|
4
|
+
class ParametersFilter
|
5
|
+
attr_reader :filters, :params_filter
|
6
|
+
|
7
|
+
def initialize(filters)
|
8
|
+
@filters = filters
|
9
|
+
@params_filter = ActiveSupport::ParameterFilter.new(filters)
|
10
|
+
end
|
11
|
+
|
12
|
+
def filter(params)
|
13
|
+
params && params_filter.filter(params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def filter_json(json_text)
|
17
|
+
return json_text if filters.blank? || json_text.blank?
|
18
|
+
|
19
|
+
begin
|
20
|
+
hash_params = JSON.parse(json_text)
|
21
|
+
filtered_params = filter(hash_params)
|
22
|
+
JSON.dump(filtered_params)
|
23
|
+
rescue JSON::ParserError
|
24
|
+
String.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -29,6 +29,10 @@ class Jets::Controller
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def filtered_parameters(**kwargs)
|
33
|
+
parameter_filter.filter params(**kwargs, raw: true) # Always filter raw hash
|
34
|
+
end
|
35
|
+
|
32
36
|
def query_parameters
|
33
37
|
event["queryStringParameters"] || {}
|
34
38
|
end
|
@@ -83,5 +87,9 @@ class Jets::Controller
|
|
83
87
|
return nil if body.nil?
|
84
88
|
Base64.decode64(body)
|
85
89
|
end
|
90
|
+
|
91
|
+
def parameter_filter
|
92
|
+
@parameter_filter ||= ParametersFilter.new Jets.config.controllers.filtered_parameters
|
93
|
+
end
|
86
94
|
end
|
87
95
|
end
|
data/lib/jets/dotenv.rb
CHANGED
@@ -22,18 +22,18 @@ class Jets::Dotenv
|
|
22
22
|
# dotenv files with the following precedence:
|
23
23
|
#
|
24
24
|
# - .env.development.jets_env_extra (highest)
|
25
|
-
# - .env.development.remote (2nd highest)
|
26
|
-
# - .env.development.local
|
25
|
+
# - .env.development.remote (2nd highest, only if JETS_ENV_REMOTE=1)
|
26
|
+
# - .env.development.local (unless JETS_ENV_REMOTE=1)
|
27
27
|
# - .env.development
|
28
|
-
# - .env.local - This file is loaded for all environments _except_ `test
|
28
|
+
# - .env.local - This file is loaded for all environments _except_ `test` or unless JETS_ENV_REMOTE=1
|
29
29
|
# - .env - The original (lowest)
|
30
30
|
#
|
31
31
|
def dotenv_files
|
32
32
|
files = [
|
33
33
|
root.join(".env"),
|
34
|
-
(root.join(".env.local") unless Jets.env.test?),
|
34
|
+
(root.join(".env.local") unless (Jets.env.test? || @remote)),
|
35
35
|
root.join(".env.#{Jets.env}"),
|
36
|
-
root.join(".env.#{Jets.env}.local"),
|
36
|
+
(root.join(".env.#{Jets.env}.local") unless @remote),
|
37
37
|
]
|
38
38
|
files << root.join(".env.#{Jets.env}.remote") if @remote
|
39
39
|
if ENV["JETS_ENV_EXTRA"]
|
@@ -8,6 +8,7 @@ module Jets
|
|
8
8
|
end
|
9
9
|
|
10
10
|
initializer "action_mailer.set_configs" do |app|
|
11
|
+
app.config.action_mailer ||= ActiveSupport::OrderedOptions.new # TODO: temp fix. only happens sometimes?
|
11
12
|
options = app.config.action_mailer
|
12
13
|
options.default_url_options ||= {}
|
13
14
|
options.default_url_options[:protocol] ||= "https"
|
data/lib/jets/job/base.rb
CHANGED
data/lib/jets/rack_server.rb
CHANGED
@@ -34,7 +34,7 @@ module Jets
|
|
34
34
|
def serve
|
35
35
|
# Note, looks like stopping jets server with Ctrl-C sends the TERM signal
|
36
36
|
# down to the sub bin/rackup command cleans up the child process fine.
|
37
|
-
Bundler.
|
37
|
+
Bundler.with_unbundled_env do
|
38
38
|
args = ''
|
39
39
|
# only forward the host option, port is always 9292 for simplicity
|
40
40
|
if @options[:host]
|
data/lib/jets/resource.rb
CHANGED
@@ -26,14 +26,14 @@ class Jets::Resource
|
|
26
26
|
Jets::Resource.truncate_id(id)
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.truncate_id(id)
|
29
|
+
def self.truncate_id(id, postfix = '')
|
30
30
|
# Api Gateway resource name has a limit of 64 characters.
|
31
31
|
# Yet it throws not found when ID is longer than 62 characters and I don't know why.
|
32
32
|
# To keep it safe, let's stick to the 62 characters limit.
|
33
|
-
if id.size > 62
|
34
|
-
"#{id[0..55]}#{Digest::MD5.hexdigest(id)[0..5]}"
|
33
|
+
if id.size + postfix.size > 62
|
34
|
+
"#{id[0..(55 - postfix.size)]}#{Digest::MD5.hexdigest(id)[0..5]}#{postfix}"
|
35
35
|
else
|
36
|
-
id
|
36
|
+
"#{id}#{postfix}"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -36,6 +36,8 @@ module Jets::Resource::ApiGateway
|
|
36
36
|
method_responses: []
|
37
37
|
}
|
38
38
|
props[:authorizer_id] = authorizer_id if authorizer_id
|
39
|
+
props[:authorization_scopes] = authorization_scopes if authorization_scopes
|
40
|
+
|
39
41
|
props
|
40
42
|
end
|
41
43
|
|
@@ -83,7 +85,7 @@ module Jets::Resource::ApiGateway
|
|
83
85
|
def resource_id
|
84
86
|
@route.path == '' ?
|
85
87
|
"RootResourceId" :
|
86
|
-
Jets::Resource.truncate_id(
|
88
|
+
Jets::Resource.truncate_id(resource_logical_id.camelize, "ApiResource")
|
87
89
|
end
|
88
90
|
|
89
91
|
# Example: Posts
|
@@ -28,5 +28,14 @@ class Jets::Resource::ApiGateway::Method
|
|
28
28
|
controller_klass.api_key_required ||
|
29
29
|
Jets.config.api.api_key_required
|
30
30
|
end
|
31
|
+
|
32
|
+
def authorization_scopes
|
33
|
+
if @route.authorization_scopes
|
34
|
+
authorization_scopes = @route.authorization_scopes
|
35
|
+
elsif controller_klass.authorization_scopes
|
36
|
+
authorization_scopes = controller_klass.authorization_scopes
|
37
|
+
end
|
38
|
+
authorization_scopes
|
39
|
+
end
|
31
40
|
end
|
32
41
|
end
|
@@ -28,7 +28,7 @@ module Jets::Resource::ApiGateway
|
|
28
28
|
if @path == ''
|
29
29
|
"RootResourceId"
|
30
30
|
else
|
31
|
-
Jets::Resource.truncate_id
|
31
|
+
Jets::Resource.truncate_id path_logical_id(@path), "ApiResource"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -41,7 +41,7 @@ module Jets::Resource::ApiGateway
|
|
41
41
|
if @path.include?('/') # posts/:id or posts/:id/edit
|
42
42
|
parent_path = @path.split('/')[0..-2].join('/')
|
43
43
|
parent_logical_id = path_logical_id(parent_path)
|
44
|
-
Jets::Resource.truncate_id("
|
44
|
+
Jets::Resource.truncate_id(parent_logical_id, "ApiResource")
|
45
45
|
else
|
46
46
|
"RootResourceId"
|
47
47
|
end
|
@@ -52,8 +52,8 @@ module Jets::Resource::Lambda
|
|
52
52
|
environment: { variables: environment },
|
53
53
|
}
|
54
54
|
|
55
|
-
|
56
|
-
baseline.merge(
|
55
|
+
application_config = Jets.application.config.function.to_h
|
56
|
+
baseline.merge(application_config)
|
57
57
|
end
|
58
58
|
|
59
59
|
# Class properties example:
|
@@ -211,4 +211,4 @@ module Jets::Resource::Lambda
|
|
211
211
|
"#{@app_class}##{@task.meth}"
|
212
212
|
end
|
213
213
|
end
|
214
|
-
end
|
214
|
+
end
|
data/lib/jets/router.rb
CHANGED
@@ -93,18 +93,18 @@ module Jets
|
|
93
93
|
# Useful for RouterMatcher
|
94
94
|
#
|
95
95
|
# Precedence:
|
96
|
-
#
|
97
|
-
# 2. Then consider the routes with captures: post/:id
|
98
|
-
# 3. Last consider the routes with wildcards: *catchall
|
96
|
+
# Routes with wildcards are considered after routes without wildcards
|
99
97
|
#
|
100
|
-
#
|
101
|
-
#
|
98
|
+
# Routes with fewer captures are ordered first since both
|
99
|
+
# /posts/:post_id/comments/new and /posts/:post_id/comments/:id are equally
|
100
|
+
# long
|
101
|
+
#
|
102
|
+
# Routes with the same amount of captures and wildcards are orderd so that
|
103
|
+
# the longest path is considered first since posts/:id and posts/:id/edit
|
104
|
+
# can both match.
|
102
105
|
def ordered_routes
|
103
|
-
length = Proc.new { |r| r.path.length * -1 }
|
104
|
-
|
105
|
-
wildcard_routes = routes.select { |r| r.path.include?('*') }.sort_by(&length)
|
106
|
-
simple_routes = (routes - capture_routes - wildcard_routes).sort_by(&length)
|
107
|
-
simple_routes + capture_routes + wildcard_routes
|
106
|
+
length = Proc.new { |r| [r.path.count("*"), r.path.count(":"), r.path.length * -1] }
|
107
|
+
routes.sort_by(&length)
|
108
108
|
end
|
109
109
|
|
110
110
|
class << self
|
data/lib/jets/turbo/rails.rb
CHANGED
@@ -110,7 +110,7 @@ class Jets::Turbo
|
|
110
110
|
# TODO: remove duplication, copied from jets/commands/import/base.rb
|
111
111
|
# And modified it slightly
|
112
112
|
def bundle_install
|
113
|
-
Bundler.
|
113
|
+
Bundler.with_unbundled_env do
|
114
114
|
sh "cd #{build_area}/#{@project_folder}/rack && bundle install"
|
115
115
|
end
|
116
116
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
default: &default
|
2
2
|
adapter: <%= @adapter %>
|
3
|
+
<% if @adapter == 'postgresql' -%>
|
4
|
+
encoding: unicode
|
5
|
+
<% else -%>
|
3
6
|
encoding: utf8mb4
|
7
|
+
<% end -%>
|
4
8
|
pool: <%%= ENV["DB_POOL"] || 5 %>
|
5
9
|
database: <%%= ENV['DB_NAME'] || '<%= @database_development %>' %>
|
6
10
|
<% if @adapter == 'postgresql' -%>
|
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: 2.3.
|
4
|
+
version: 2.3.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -332,20 +332,6 @@ dependencies:
|
|
332
332
|
- - ">="
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: '0'
|
335
|
-
- !ruby/object:Gem::Dependency
|
336
|
-
name: json
|
337
|
-
requirement: !ruby/object:Gem::Requirement
|
338
|
-
requirements:
|
339
|
-
- - ">="
|
340
|
-
- !ruby/object:Gem::Version
|
341
|
-
version: '0'
|
342
|
-
type: :runtime
|
343
|
-
prerelease: false
|
344
|
-
version_requirements: !ruby/object:Gem::Requirement
|
345
|
-
requirements:
|
346
|
-
- - ">="
|
347
|
-
- !ruby/object:Gem::Version
|
348
|
-
version: '0'
|
349
335
|
- !ruby/object:Gem::Dependency
|
350
336
|
name: kramdown
|
351
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -786,6 +772,7 @@ files:
|
|
786
772
|
- lib/jets/controller/middleware/main.rb
|
787
773
|
- lib/jets/controller/middleware/reloader.rb
|
788
774
|
- lib/jets/controller/middleware/webpacker_setup.rb
|
775
|
+
- lib/jets/controller/parameters_filter.rb
|
789
776
|
- lib/jets/controller/params.rb
|
790
777
|
- lib/jets/controller/rack/adapter.rb
|
791
778
|
- lib/jets/controller/rack/env.rb
|
@@ -796,6 +783,7 @@ files:
|
|
796
783
|
- lib/jets/controller/response.rb
|
797
784
|
- lib/jets/controller/stage.rb
|
798
785
|
- lib/jets/core.rb
|
786
|
+
- lib/jets/core_ext/bundler.rb
|
799
787
|
- lib/jets/core_ext/kernel.rb
|
800
788
|
- lib/jets/db.rb
|
801
789
|
- lib/jets/dotenv.rb
|