jets 2.3.13 → 2.3.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1c15ea91434727519b1531096940a485671580c71718567d2f2789d49b52919
4
- data.tar.gz: 16b9fad79824140e0733c9753093d8e0ba969d6f8658cc0a2d846953cbbda3db
3
+ metadata.gz: ddbf1726e80a44319389bf13b4b22323517ae715d552fc503fe3b48dbc89160b
4
+ data.tar.gz: 4671ee27bbb47bb3c413de748cc0c01ef3bdf14289f4cf28d0690f9019e7f269
5
5
  SHA512:
6
- metadata.gz: f51fcf5b4ddb7bcfd2423556c6bb6871471ae487dc83a5ed080896276236dfedc8785e310e6862659f54dce8a61decb8baedf3f61b62c65f0bf79438d86d6ac1
7
- data.tar.gz: 9d4c6f4924acc0c62ea93265a94d1acc68436b5a41c9e9d1ae56c0b3325542f5a947b6b294ae88d6c7b17089aeab834ff675a1d60601b3365f7e282ae66e0526
6
+ metadata.gz: ad4a8ceb595f021253d2f93bb3ec70c06a58d574478d3be3503756926ee1d3ca85e39f633aadba9499c8d741d86bccd44cd249a3d063a109e6c77397bbfad74c
7
+ data.tar.gz: f00bcab89a774abea67c64a3b9aaf96a1b64ac0778303ac11a38043c343a7fd3cf9b2966bb92e1ee39603dc76d5b5eacdad157dcd0908e3c1bdc681d0bd892bc
@@ -3,6 +3,14 @@
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.14]
7
+ - #432 filtered_parameters support
8
+ - #447 improve nested routes support. order routes so that nested resources always work
9
+ - #451 Fix Jets turbo DB encoding
10
+ - #452 Print Cfn templates location after build
11
+ - #458 update webpacker fork with jetpacker gem
12
+ - #459 fix afterburner mode
13
+
6
14
  ## [2.3.13]
7
15
  - #430 Remove out-of-date note about FIFO Queue
8
16
  - #433 Fixed ApiResources with long names not included in the main CloudFormation template
data/Gemfile CHANGED
@@ -9,6 +9,6 @@ gemspec
9
9
  group :development, :test do
10
10
  gem "mysql2", "~> 0.5.2"
11
11
  gem "dynomite"
12
- gem "webpacker", git: "https://github.com/tongueroo/webpacker.git", branch: "jets"
12
+ gem "jetpacker"
13
13
  gem "rspec_junit_formatter"
14
14
  end
@@ -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
@@ -99,8 +99,17 @@ module Jets::Builders
99
99
 
100
100
  # Code prep and zipping
101
101
  check_code_size!
102
- generate_shims
103
- calculate_md5s # must be called before create_zip_files because checksums need to be populated
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
@@ -6,7 +6,9 @@ module Jets::Builders
6
6
  end
7
7
 
8
8
  def run
9
- check = Jets::Gems::Check.new
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
@@ -32,6 +32,7 @@ module Jets::Commands
32
32
  clean_templates
33
33
  build_minimal_template
34
34
  build_all_templates if full?
35
+ puts "Generated CloudFormation templates at #{Jets.build_root}/templates"
35
36
  end
36
37
 
37
38
  def full?
@@ -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(cli: true)
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 👍"
@@ -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.
@@ -1,10 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "jets"
3
+ gem "jets", git: "https://github.com/tongueroo/jets.git", submodules: true, branch: "master"
4
4
 
5
5
  <% if @webpacker -%>
6
- # Include webpacker if you are you are building html pages
7
- gem "webpacker", git: "https://github.com/tongueroo/webpacker.git", branch: "jets"
6
+ # Include jetpacker if you are 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 and Jets, along with any other files
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 -%>
@@ -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: #{json_dump(display_event)}"
110
- Jets.logger.info " Parameters: #{JSON.dump(params(raw: true).to_h)}"
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
@@ -93,18 +93,18 @@ module Jets
93
93
  # Useful for RouterMatcher
94
94
  #
95
95
  # Precedence:
96
- # 1. Routes with no captures get highest precedence: posts/new
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
- # Within these 2 groups we consider the routes with the longest path first
101
- # since posts/:id and posts/:id/edit can both match.
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
- capture_routes = routes.select { |r| r.path.include?(':') }.sort_by(&length)
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
@@ -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' -%>
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "2.3.13"
2
+ VERSION = "2.3.14"
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: 2.3.13
4
+ version: 2.3.14
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-02-23 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -786,6 +786,7 @@ files:
786
786
  - lib/jets/controller/middleware/main.rb
787
787
  - lib/jets/controller/middleware/reloader.rb
788
788
  - lib/jets/controller/middleware/webpacker_setup.rb
789
+ - lib/jets/controller/parameters_filter.rb
789
790
  - lib/jets/controller/params.rb
790
791
  - lib/jets/controller/rack/adapter.rb
791
792
  - lib/jets/controller/rack/env.rb