rack-reducer 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +112 -252
  3. data/lib/rack/reducer/middleware.rb +17 -2
  4. data/lib/rack/reducer/reduction.rb +19 -16
  5. data/lib/rack/reducer/refinements.rb +13 -1
  6. data/lib/rack/reducer/version.rb +3 -1
  7. data/lib/rack/reducer/warnings.rb +27 -0
  8. data/lib/rack/reducer.rb +51 -20
  9. data/spec/benchmarks.rb +51 -21
  10. data/spec/fixtures.rb +30 -0
  11. data/spec/middleware_spec.rb +55 -23
  12. data/spec/rails_spec.rb +33 -3
  13. data/spec/reducer_spec.rb +104 -0
  14. data/spec/spec_helper.rb +6 -15
  15. metadata +34 -136
  16. data/lib/rack/reducer/parser.rb +0 -26
  17. data/spec/_hanami_example/apps/web/application.rb +0 -326
  18. data/spec/_hanami_example/apps/web/config/routes.rb +0 -4
  19. data/spec/_hanami_example/apps/web/controllers/artists/index.rb +0 -12
  20. data/spec/_hanami_example/apps/web/views/application_layout.rb +0 -7
  21. data/spec/_hanami_example/config/boot.rb +0 -2
  22. data/spec/_hanami_example/config/environment.rb +0 -29
  23. data/spec/_hanami_example/lib/hanami_example/entities/artist.rb +0 -2
  24. data/spec/_hanami_example/lib/hanami_example/repositories/artist_repository.rb +0 -9
  25. data/spec/_hanami_example/lib/hanami_example.rb +0 -5
  26. data/spec/_rails_example/app/channels/application_cable/channel.rb +0 -4
  27. data/spec/_rails_example/app/channels/application_cable/connection.rb +0 -4
  28. data/spec/_rails_example/app/controllers/application_controller.rb +0 -2
  29. data/spec/_rails_example/app/controllers/artists_controller.rb +0 -8
  30. data/spec/_rails_example/app/jobs/application_job.rb +0 -2
  31. data/spec/_rails_example/app/mailers/application_mailer.rb +0 -4
  32. data/spec/_rails_example/app/models/application_record.rb +0 -3
  33. data/spec/_rails_example/app/models/rails_example/artist.rb +0 -21
  34. data/spec/_rails_example/config/application.rb +0 -35
  35. data/spec/_rails_example/config/boot.rb +0 -3
  36. data/spec/_rails_example/config/environment.rb +0 -5
  37. data/spec/_rails_example/config/environments/development.rb +0 -47
  38. data/spec/_rails_example/config/environments/production.rb +0 -83
  39. data/spec/_rails_example/config/environments/test.rb +0 -42
  40. data/spec/_rails_example/config/initializers/application_controller_renderer.rb +0 -8
  41. data/spec/_rails_example/config/initializers/backtrace_silencers.rb +0 -7
  42. data/spec/_rails_example/config/initializers/cors.rb +0 -16
  43. data/spec/_rails_example/config/initializers/filter_parameter_logging.rb +0 -4
  44. data/spec/_rails_example/config/initializers/inflections.rb +0 -16
  45. data/spec/_rails_example/config/initializers/mime_types.rb +0 -4
  46. data/spec/_rails_example/config/initializers/wrap_parameters.rb +0 -14
  47. data/spec/_rails_example/config/puma.rb +0 -56
  48. data/spec/_rails_example/config/routes.rb +0 -4
  49. data/spec/_rails_example/db/seeds.rb +0 -7
  50. data/spec/behavior.rb +0 -51
  51. data/spec/hanami_spec.rb +0 -6
  52. data/spec/roda_spec.rb +0 -13
  53. data/spec/sinatra_functional_spec.rb +0 -26
  54. data/spec/sinatra_mixin_spec.rb +0 -20
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-reducer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2019-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '5.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: benchmark-ips
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.7'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.7'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: benchmark-memory
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0.11'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0.11'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: hanami
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '2'
69
69
  - !ruby/object:Gem::Dependency
70
- name: hanami-model
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1'
75
+ version: '0.11'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1'
82
+ version: '0.11'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack-test
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,19 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rails
98
+ name: railties
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '5'
103
+ version: '5.2'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '5'
110
+ version: '5.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '12'
125
- - !ruby/object:Gem::Dependency
126
- name: roda
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '3'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: rspec
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -170,28 +156,14 @@ dependencies:
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: '4'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '4'
181
- - !ruby/object:Gem::Dependency
182
- name: sinatra
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '2'
159
+ version: '5'
188
160
  type: :development
189
161
  prerelease: false
190
162
  version_requirements: !ruby/object:Gem::Requirement
191
163
  requirements:
192
164
  - - "~>"
193
165
  - !ruby/object:Gem::Version
194
- version: '2'
166
+ version: '5'
195
167
  - !ruby/object:Gem::Dependency
196
168
  name: sqlite3
197
169
  requirement: !ruby/object:Gem::Requirement
@@ -240,8 +212,7 @@ dependencies:
240
212
  - - "<"
241
213
  - !ruby/object:Gem::Version
242
214
  version: '3'
243
- description: Dynamically filter, sort, and paginate data via URL params, in any Rack
244
- app.
215
+ description: Declaratively filter data via URL params, in any Rack app.
245
216
  email:
246
217
  - chris.frank@future.com
247
218
  executables: []
@@ -251,51 +222,15 @@ files:
251
222
  - README.md
252
223
  - lib/rack/reducer.rb
253
224
  - lib/rack/reducer/middleware.rb
254
- - lib/rack/reducer/parser.rb
255
225
  - lib/rack/reducer/reduction.rb
256
226
  - lib/rack/reducer/refinements.rb
257
227
  - lib/rack/reducer/version.rb
258
- - spec/_hanami_example/apps/web/application.rb
259
- - spec/_hanami_example/apps/web/config/routes.rb
260
- - spec/_hanami_example/apps/web/controllers/artists/index.rb
261
- - spec/_hanami_example/apps/web/views/application_layout.rb
262
- - spec/_hanami_example/config/boot.rb
263
- - spec/_hanami_example/config/environment.rb
264
- - spec/_hanami_example/lib/hanami_example.rb
265
- - spec/_hanami_example/lib/hanami_example/entities/artist.rb
266
- - spec/_hanami_example/lib/hanami_example/repositories/artist_repository.rb
267
- - spec/_rails_example/app/channels/application_cable/channel.rb
268
- - spec/_rails_example/app/channels/application_cable/connection.rb
269
- - spec/_rails_example/app/controllers/application_controller.rb
270
- - spec/_rails_example/app/controllers/artists_controller.rb
271
- - spec/_rails_example/app/jobs/application_job.rb
272
- - spec/_rails_example/app/mailers/application_mailer.rb
273
- - spec/_rails_example/app/models/application_record.rb
274
- - spec/_rails_example/app/models/rails_example/artist.rb
275
- - spec/_rails_example/config/application.rb
276
- - spec/_rails_example/config/boot.rb
277
- - spec/_rails_example/config/environment.rb
278
- - spec/_rails_example/config/environments/development.rb
279
- - spec/_rails_example/config/environments/production.rb
280
- - spec/_rails_example/config/environments/test.rb
281
- - spec/_rails_example/config/initializers/application_controller_renderer.rb
282
- - spec/_rails_example/config/initializers/backtrace_silencers.rb
283
- - spec/_rails_example/config/initializers/cors.rb
284
- - spec/_rails_example/config/initializers/filter_parameter_logging.rb
285
- - spec/_rails_example/config/initializers/inflections.rb
286
- - spec/_rails_example/config/initializers/mime_types.rb
287
- - spec/_rails_example/config/initializers/wrap_parameters.rb
288
- - spec/_rails_example/config/puma.rb
289
- - spec/_rails_example/config/routes.rb
290
- - spec/_rails_example/db/seeds.rb
291
- - spec/behavior.rb
228
+ - lib/rack/reducer/warnings.rb
292
229
  - spec/benchmarks.rb
293
- - spec/hanami_spec.rb
230
+ - spec/fixtures.rb
294
231
  - spec/middleware_spec.rb
295
232
  - spec/rails_spec.rb
296
- - spec/roda_spec.rb
297
- - spec/sinatra_functional_spec.rb
298
- - spec/sinatra_mixin_spec.rb
233
+ - spec/reducer_spec.rb
299
234
  - spec/spec_helper.rb
300
235
  homepage: https://github.com/chrisfrank/rack-reducer
301
236
  licenses:
@@ -309,58 +244,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
309
244
  requirements:
310
245
  - - ">="
311
246
  - !ruby/object:Gem::Version
312
- version: '2.2'
247
+ version: '2.3'
313
248
  required_rubygems_version: !ruby/object:Gem::Requirement
314
249
  requirements:
315
250
  - - ">="
316
251
  - !ruby/object:Gem::Version
317
252
  version: '0'
318
253
  requirements: []
319
- rubyforge_project:
320
- rubygems_version: 2.7.6
254
+ rubygems_version: 3.0.2
321
255
  signing_key:
322
256
  specification_version: 4
323
- summary: Dynamically filter data via URL params, in any Rack app.
257
+ summary: Declaratively filter data via URL params, in any Rack app.
324
258
  test_files:
325
259
  - spec/spec_helper.rb
326
260
  - spec/benchmarks.rb
327
- - spec/sinatra_mixin_spec.rb
328
- - spec/_rails_example/app/mailers/application_mailer.rb
329
- - spec/_rails_example/app/models/rails_example/artist.rb
330
- - spec/_rails_example/app/models/application_record.rb
331
- - spec/_rails_example/app/jobs/application_job.rb
332
- - spec/_rails_example/app/controllers/application_controller.rb
333
- - spec/_rails_example/app/controllers/artists_controller.rb
334
- - spec/_rails_example/app/channels/application_cable/connection.rb
335
- - spec/_rails_example/app/channels/application_cable/channel.rb
336
- - spec/_rails_example/config/routes.rb
337
- - spec/_rails_example/config/environments/production.rb
338
- - spec/_rails_example/config/environments/development.rb
339
- - spec/_rails_example/config/environments/test.rb
340
- - spec/_rails_example/config/environment.rb
341
- - spec/_rails_example/config/application.rb
342
- - spec/_rails_example/config/puma.rb
343
- - spec/_rails_example/config/boot.rb
344
- - spec/_rails_example/config/initializers/application_controller_renderer.rb
345
- - spec/_rails_example/config/initializers/backtrace_silencers.rb
346
- - spec/_rails_example/config/initializers/mime_types.rb
347
- - spec/_rails_example/config/initializers/filter_parameter_logging.rb
348
- - spec/_rails_example/config/initializers/wrap_parameters.rb
349
- - spec/_rails_example/config/initializers/inflections.rb
350
- - spec/_rails_example/config/initializers/cors.rb
351
- - spec/_rails_example/db/seeds.rb
352
- - spec/_hanami_example/config/environment.rb
353
- - spec/_hanami_example/config/boot.rb
354
- - spec/_hanami_example/lib/hanami_example/repositories/artist_repository.rb
355
- - spec/_hanami_example/lib/hanami_example/entities/artist.rb
356
- - spec/_hanami_example/lib/hanami_example.rb
357
- - spec/_hanami_example/apps/web/config/routes.rb
358
- - spec/_hanami_example/apps/web/application.rb
359
- - spec/_hanami_example/apps/web/controllers/artists/index.rb
360
- - spec/_hanami_example/apps/web/views/application_layout.rb
361
- - spec/sinatra_functional_spec.rb
261
+ - spec/fixtures.rb
362
262
  - spec/middleware_spec.rb
363
- - spec/roda_spec.rb
364
- - spec/hanami_spec.rb
365
- - spec/behavior.rb
263
+ - spec/reducer_spec.rb
366
264
  - spec/rails_spec.rb
@@ -1,26 +0,0 @@
1
- module Rack
2
- module Reducer
3
- # Convert params from Sinatra, Rails, Roda, etc into a symbol hash.
4
- module Parser
5
- def self.call(data)
6
- data.is_a?(Hash) ? symbolize(data) : hashify(data)
7
- end
8
-
9
- def self.symbolize(data)
10
- data.each_with_object({}) do |(key, val), hash|
11
- hash[key.to_sym] = val.is_a?(Hash) ? symbolize(val) : val
12
- end
13
- end
14
-
15
- # Turns out a Rails params hash is not really a hash.
16
- # It's safe to call .to_unsafe_hash here, because params
17
- # are automatically sanitized by the lambda keywords.
18
- def self.hashify(data)
19
- fn = %i[to_unsafe_h to_h].find { |name| data.respond_to?(name) }
20
- symbolize(data.send(fn))
21
- end
22
- end
23
-
24
- private_constant :Parser
25
- end
26
- end
@@ -1,326 +0,0 @@
1
- require 'hanami/helpers'
2
- require 'hanami/assets'
3
-
4
- module Web
5
- class Application < Hanami::Application
6
- configure do
7
- ##
8
- # BASIC
9
- #
10
-
11
- # Define the root path of this application.
12
- # All paths specified in this configuration are relative to path below.
13
- #
14
- root __dir__
15
-
16
- # Relative load paths where this application will recursively load the
17
- # code.
18
- #
19
- # When you add new directories, remember to add them here.
20
- #
21
- load_paths << [
22
- 'controllers',
23
- 'views'
24
- ]
25
-
26
- # Handle exceptions with HTTP statuses (true) or don't catch them (false).
27
- # Defaults to true.
28
- # See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
29
- #
30
- # handle_exceptions true
31
-
32
- ##
33
- # HTTP
34
- #
35
-
36
- # Routes definitions for this application
37
- # See: http://www.rubydoc.info/gems/hanami-router#Usage
38
- #
39
- routes 'config/routes'
40
-
41
- # URI scheme used by the routing system to generate absolute URLs
42
- # Defaults to "http"
43
- #
44
- # scheme 'https'
45
-
46
- # URI host used by the routing system to generate absolute URLs
47
- # Defaults to "localhost"
48
- #
49
- # host 'example.org'
50
-
51
- # URI port used by the routing system to generate absolute URLs
52
- # Argument: An object coercible to integer, defaults to 80 if the scheme
53
- # is http and 443 if it's https
54
- #
55
- # This should only be configured if app listens to non-standard ports
56
- #
57
- # port 443
58
-
59
- # Enable cookies
60
- # Argument: boolean to toggle the feature
61
- # A Hash with options
62
- #
63
- # Options:
64
- # :domain - The domain (String - nil by default, not required)
65
- # :path - Restrict cookies to a relative URI
66
- # (String - nil by default)
67
- # :max_age - Cookies expiration expressed in seconds
68
- # (Integer - nil by default)
69
- # :secure - Restrict cookies to secure connections
70
- # (Boolean - Automatically true when using HTTPS)
71
- # See #scheme and #ssl?
72
- # :httponly - Prevent JavaScript access (Boolean - true by default)
73
- #
74
- # cookies true
75
- # or
76
- # cookies max_age: 300
77
-
78
- # Enable sessions
79
- # Argument: Symbol the Rack session adapter
80
- # A Hash with options
81
- #
82
- # See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
83
- #
84
- # sessions :cookie, secret: ENV['WEB_SESSIONS_SECRET']
85
-
86
- # Configure Rack middleware for this application
87
- #
88
- # middleware.use Rack::Protection
89
-
90
- # Default format for the requests that don't specify an HTTP_ACCEPT header
91
- # Argument: A symbol representation of a mime type, defaults to :html
92
- #
93
- default_request_format :json
94
-
95
- # Default format for responses that don't consider the request format
96
- # Argument: A symbol representation of a mime type, defaults to :html
97
- #
98
- default_response_format :json
99
-
100
- # HTTP Body parsers
101
- # Parse non GET responses body for a specific mime type
102
- # Argument: Symbol, which represent the format of the mime type
103
- # (only `:json` is supported)
104
- # Object, the parser
105
- #
106
- # body_parsers :json
107
-
108
- # When it's true and the router receives a non-encrypted request (http),
109
- # it redirects to the secure equivalent (https). Disabled by default.
110
- #
111
- # force_ssl true
112
-
113
- ##
114
- # TEMPLATES
115
- #
116
-
117
- # The layout to be used by all views
118
- #
119
- layout :application # It will load Web::Views::ApplicationLayout
120
-
121
- # The relative path to templates
122
- #
123
- templates 'templates'
124
-
125
- ##
126
- # ASSETS
127
- #
128
- assets do
129
- # JavaScript compressor
130
- #
131
- # Supported engines:
132
- #
133
- # * :builtin
134
- # * :uglifier
135
- # * :yui
136
- # * :closure
137
- #
138
- # See: http://hanamirb.org/guides/assets/compressors
139
- #
140
- # In order to skip JavaScript compression comment the following line
141
- javascript_compressor :builtin
142
-
143
- # Stylesheet compressor
144
- #
145
- # Supported engines:
146
- #
147
- # * :builtin
148
- # * :yui
149
- # * :sass
150
- #
151
- # See: http://hanamirb.org/guides/assets/compressors
152
- #
153
- # In order to skip stylesheet compression comment the following line
154
- stylesheet_compressor :builtin
155
-
156
- # Specify sources for assets
157
- #
158
- sources << [
159
- 'assets'
160
- ]
161
- end
162
-
163
- ##
164
- # SECURITY
165
- #
166
-
167
- # X-Frame-Options is a HTTP header supported by modern browsers.
168
- # It determines if a web page can or cannot be included via <frame> and
169
- # <iframe> tags by untrusted domains.
170
- #
171
- # Web applications can send this header to prevent Clickjacking attacks.
172
- #
173
- # Read more at:
174
- #
175
- # * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
176
- # * https://www.owasp.org/index.php/Clickjacking
177
- #
178
- security.x_frame_options 'DENY'
179
-
180
- # X-Content-Type-Options prevents browsers from interpreting files as
181
- # something else than declared by the content type in the HTTP headers.
182
- #
183
- # Read more at:
184
- #
185
- # * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
186
- # * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
187
- # * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
188
- #
189
- security.x_content_type_options 'nosniff'
190
-
191
- # X-XSS-Protection is a HTTP header to determine the behavior of the
192
- # browser in case an XSS attack is detected.
193
- #
194
- # Read more at:
195
- #
196
- # * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
197
- # * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
198
- #
199
- security.x_xss_protection '1; mode=block'
200
-
201
- # Content-Security-Policy (CSP) is a HTTP header supported by modern
202
- # browsers. It determines trusted sources of execution for dynamic
203
- # contents (JavaScript) or other web related assets: stylesheets, images,
204
- # fonts, plugins, etc.
205
- #
206
- # Web applications can send this header to mitigate Cross Site Scripting
207
- # (XSS) attacks.
208
- #
209
- # The default value allows images, scripts, AJAX, fonts and CSS from the
210
- # same origin, and does not allow any other resources to load (eg object,
211
- # frame, media, etc).
212
- #
213
- # Inline JavaScript is NOT allowed. To enable it, please use:
214
- # "script-src 'unsafe-inline'".
215
- #
216
- # Content Security Policy introduction:
217
- #
218
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
219
- # * https://www.owasp.org/index.php/Content_Security_Policy
220
- # * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
221
- #
222
- # Inline and eval JavaScript risks:
223
- #
224
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
225
- # * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
226
- #
227
- # Content Security Policy usage:
228
- #
229
- # * http://content-security-policy.com/
230
- # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
231
- #
232
- # Content Security Policy references:
233
- #
234
- # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
235
- #
236
- security.content_security_policy %{
237
- form-action 'self';
238
- frame-ancestors 'self';
239
- base-uri 'self';
240
- default-src 'none';
241
- script-src 'self';
242
- connect-src 'self';
243
- img-src 'self' https: data:;
244
- style-src 'self' 'unsafe-inline' https:;
245
- font-src 'self';
246
- object-src 'none';
247
- plugin-types application/pdf;
248
- child-src 'self';
249
- frame-src 'self';
250
- media-src 'self'
251
- }
252
-
253
- ##
254
- # FRAMEWORKS
255
- #
256
-
257
- # Configure the code that will yield each time Web::Action is included
258
- # This is useful for sharing common functionality
259
- #
260
- # See: http://www.rubydoc.info/gems/hanami-controller#Configuration
261
- controller.prepare do
262
- # include MyAuthentication # included in all the actions
263
- # before :authenticate! # run an authentication before callback
264
- end
265
-
266
- # Configure the code that will yield each time Web::View is included
267
- # This is useful for sharing common functionality
268
- #
269
- # See: http://www.rubydoc.info/gems/hanami-view#Configuration
270
- view.prepare do
271
- include Hanami::Helpers
272
- include Web::Assets::Helpers
273
- end
274
- end
275
-
276
- ##
277
- # DEVELOPMENT
278
- #
279
- configure :development do
280
- # Don't handle exceptions, render the stack trace
281
- handle_exceptions false
282
- end
283
-
284
- ##
285
- # TEST
286
- #
287
- configure :test do
288
- # Don't handle exceptions, render the stack trace
289
- handle_exceptions false
290
- end
291
-
292
- ##
293
- # PRODUCTION
294
- #
295
- configure :production do
296
- # scheme 'https'
297
- # host 'example.org'
298
- # port 443
299
-
300
- assets do
301
- # Don't compile static assets in production mode (eg. Sass, ES6)
302
- #
303
- # See: http://www.rubydoc.info/gems/hanami-assets#Configuration
304
- compile false
305
-
306
- # Use fingerprint file name for asset paths
307
- #
308
- # See: http://hanamirb.org/guides/assets/overview
309
- fingerprint true
310
-
311
- # Content Delivery Network (CDN)
312
- #
313
- # See: http://hanamirb.org/guides/assets/content-delivery-network
314
- #
315
- # scheme 'https'
316
- # host 'cdn.example.org'
317
- # port 443
318
-
319
- # Subresource Integrity
320
- #
321
- # See: http://hanamirb.org/guides/assets/content-delivery-network/#subresource-integrity
322
- subresource_integrity :sha256
323
- end
324
- end
325
- end
326
- end
@@ -1,4 +0,0 @@
1
- # Configure your routes here
2
- # See: http://hanamirb.org/guides/routing/overview/
3
- #
4
- get '/artists', to: 'artists#index'
@@ -1,12 +0,0 @@
1
- require_relative '../../../../lib/hanami_example'
2
-
3
- module Web::Controllers::Artists
4
- class Index
5
- include Web::Action
6
-
7
- def call(params)
8
- @artists = ArtistRepository.new.reduce(params).to_a
9
- self.body = @artists.to_json
10
- end
11
- end
12
- end
@@ -1,7 +0,0 @@
1
- module Web
2
- module Views
3
- class ApplicationLayout
4
- include Web::Layout
5
- end
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- require_relative './environment'
2
- Hanami.boot