eivo-rails-api 0.1.4 → 0.1.9

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: 6eb8fb502dfece3bbee217a7ad9b0cc1ec3addf89006a76cf5b0dc95cd4512b2
4
- data.tar.gz: 2708e0777b8c6ff61c316c204a5008c2640d7a98f43b99427af2a22dcc728216
3
+ metadata.gz: d26122daa50eea4591dfb5e59b7f03bb58b32c02b6dd3c770e4197bf74058ac1
4
+ data.tar.gz: 37c9a1bcaaf83ccdf406a8fbd6fcac62396805597081f36d378c8327a273fac5
5
5
  SHA512:
6
- metadata.gz: 707f5dc1d2a49d3b82ad1a35788275302cad5da6295200dbe3d8e06bfae37acd5586db50fbb371b085d8d701a9831a91217e9f6cafee02dc1e1b11ab0c6cb308
7
- data.tar.gz: 193ed57465548b16a7876ac1bdc5f34dbf816d26fb5c41c0b0ac63329cf212246a1ae9d13a0e75e0f7853cb9e7df410b6c2baaa52301e1ff3c0ff13f2fd858bb
6
+ metadata.gz: 6561c1ccabc788339a7b27032375dee85e4ccd2d4c2e27dc9fd50e4e43b4af76284e9c03d25dfdee32b09a95774e14f378d6675e3e50262d8539289b69f58c10
7
+ data.tar.gz: 64db5e1ecd54e0eb03a84ede95df803eae130ccfc3fa8d15cbe28d10fd8222bd9e0c76ee9c5c6853dd6708b617b7608b568912d89a3a7876121bb33b0eb37047
@@ -44,9 +44,6 @@ Naming/PredicateName:
44
44
  Naming/VariableNumber:
45
45
  EnforcedStyle: snake_case
46
46
 
47
- Style/BracesAroundHashParameters:
48
- EnforcedStyle: context_dependent
49
-
50
47
  Style/Documentation:
51
48
  Enabled: false
52
49
 
data/README.md CHANGED
@@ -37,10 +37,6 @@ sentry:
37
37
  dsn: ""
38
38
  ```
39
39
 
40
- ### Warning
41
-
42
- `force_ssl` option is not enabled, for performance reasons SSL / TLS should be managed by the web server (nginx, Apache).
43
-
44
40
  ## License
45
41
 
46
42
  This project is released under the MIT license. See the LICENSE file for more info.
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lograge'
4
+
5
+ if Rails.env.staging? || Rails.env.production?
6
+ Rails.application.configure do
7
+ config.colorize_logging = false
8
+
9
+ config.lograge.enabled = true
10
+ config.lograge.formatter = ::Lograge::Formatters::Raw.new
11
+ config.lograge.base_controller_class = [
12
+ 'ActionController::API',
13
+ 'ActionController::Base'
14
+ ]
15
+
16
+ config.lograge.ignore_actions = ['EIVO::StatusController#index']
17
+
18
+ config.lograge.custom_options = ->(event) do
19
+ result = {
20
+ params: event.payload[:params].except('controller', 'action', 'format'),
21
+ request_id: event.payload[:request_id]
22
+ }
23
+
24
+ result[:user_id] = event.payload[:user_id] if event.payload[:user_id]
25
+ result[:organization_id] = event.payload[:organization_id] if event.payload[:organization_id]
26
+
27
+ # https://github.com/roidrage/lograge/pull/307
28
+ if event.respond_to?(:allocations)
29
+ result[:allocations] = event.allocations
30
+ end
31
+
32
+ result
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'eivo-rails-api'
7
- spec.version = '0.1.4'
7
+ spec.version = '0.1.9'
8
8
  spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
9
9
  spec.email = ['jonathan@eivo.co']
10
10
 
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'kaminari'
29
29
 
30
+ spec.add_dependency 'lograge'
30
31
  spec.add_dependency 'sentry-raven'
31
32
 
32
33
  spec.add_development_dependency 'bundler'
@@ -9,6 +9,7 @@ require 'fast_jsonapi'
9
9
  require 'kaminari'
10
10
 
11
11
  require_relative 'eivo-rails-api/engine'
12
+ require_relative 'eivo-rails-api/formatter'
12
13
 
13
14
  module EIVO
14
15
  class << self
@@ -39,7 +39,7 @@ module EIVO
39
39
  # Highlight code that triggered database queries in logs.
40
40
  config.active_record.verbose_query_logs = true
41
41
 
42
- # Raises error for missing translations
42
+ # Raises error for missing translations.
43
43
  # config.action_view.raise_on_missing_translations = true
44
44
 
45
45
  # Use an evented file watcher to asynchronously detect changes in source code,
@@ -16,7 +16,7 @@ module EIVO
16
16
  config.eager_load = true
17
17
 
18
18
  # Full error reports are disabled and caching is turned on.
19
- config.consider_all_requests_local = false
19
+ config.consider_all_requests_local = false
20
20
 
21
21
  # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
22
22
  # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
@@ -31,10 +31,11 @@ module EIVO
31
31
 
32
32
  # Specifies the header that your server uses for sending files.
33
33
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
34
- config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
34
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
35
35
 
36
36
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
37
- # config.force_ssl = true
37
+ config.force_ssl = true
38
+ config.ssl_options = { redirect: { exclude: ->(request) { request.path == '/status' } } }
38
39
 
39
40
  # Use the lowest log level to ensure availability of diagnostic information
40
41
  # when problems arise.
@@ -46,7 +47,7 @@ module EIVO
46
47
  # Use a different cache store in production.
47
48
  # config.cache_store = :mem_cache_store
48
49
 
49
- # Use a real queuing backend for Active Job (and separate queues per environment)
50
+ # Use a real queuing backend for Active Job (and separate queues per environment).
50
51
  # config.active_job.queue_adapter = :resque
51
52
  # config.active_job.queue_name_prefix = "example_#{Rails.env}"
52
53
 
@@ -65,9 +66,15 @@ module EIVO
65
66
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
66
67
 
67
68
  if ENV['RAILS_LOG_TO_STDOUT'].present?
68
- logger = ActiveSupport::Logger.new(STDOUT)
69
+ # logger = ActiveSupport::Logger.new(STDOUT)
70
+ # logger.formatter = config.log_formatter
71
+ # config.logger = ActiveSupport::TaggedLogging.new(logger)
72
+
73
+ config.log_formatter = ::EIVO::Formatter.new
74
+ logger = ActiveSupport::Logger.new(STDOUT)
69
75
  logger.formatter = config.log_formatter
70
- config.logger = ActiveSupport::TaggedLogging.new(logger)
76
+ config.log_level = :info
77
+ config.logger = logger
71
78
  end
72
79
 
73
80
  # Do not dump schema after migrations.
@@ -3,6 +3,10 @@
3
3
  module EIVO
4
4
  class Environment
5
5
  def self.test
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
6
10
  Rails.application.configure do
7
11
  # Settings specified here will take precedence over those in config/application.rb.
8
12
 
@@ -33,7 +37,7 @@ module EIVO
33
37
  # Print deprecation notices to the stderr.
34
38
  config.active_support.deprecation = :stderr
35
39
 
36
- # Raises error for missing translations
40
+ # Raises error for missing translations.
37
41
  # config.action_view.raise_on_missing_translations = true
38
42
  end
39
43
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'multi_json'
5
+
6
+ module EIVO
7
+ class Formatter < ::Logger::Formatter
8
+ def call(severity, timestamp, progname, message)
9
+ json = {
10
+ pid: $PROCESS_ID,
11
+ level: severity,
12
+ timestamp: timestamp.utc.iso8601(3),
13
+ message: message
14
+ }
15
+
16
+ if progname
17
+ json[:tag] = progname
18
+ end
19
+
20
+ if defined?(::Sidekiq)
21
+ context = ::Sidekiq::Context.current
22
+
23
+ if !context.empty?
24
+ json[:context] = context
25
+ end
26
+ end
27
+
28
+ MultiJson.dump(json) << "\n"
29
+ end
30
+ end
31
+ end
@@ -3,9 +3,9 @@
3
3
  source 'https://rubygems.org'
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- ruby '2.6.3'
6
+ ruby '2.7.1'
7
7
 
8
- gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
8
+ gem 'rails', '~> 6.0.3', '>= 6.0.3.1'
9
9
  gem 'pg', '>= 0.18', '< 2.0'
10
10
  gem 'puma', '~> 4.1'
11
11
 
@@ -14,7 +14,7 @@ group :development, :test do
14
14
  end
15
15
 
16
16
  group :development do
17
- gem 'listen', '>= 3.0.5', '< 3.2'
17
+ gem 'listen', '~> 3.2'
18
18
  end
19
19
 
20
20
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@@ -9,7 +9,7 @@ environment ENV.fetch('RAILS_ENV') { 'development' }
9
9
  if %w[production staging].include?(ENV['RAILS_ENV'])
10
10
  pidfile 'tmp/pids/puma.pid'
11
11
  state_path 'tmp/pids/puma.state'
12
- daemonize !ENV['RAILS_DAEMONIZE'].nil?
12
+ daemonize ENV.fetch('RAILS_DAEMONIZE') { false }
13
13
 
14
14
  if ENV['PORT']
15
15
  bind "tcp://0.0.0.0:#{ENV['PORT']}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eivo-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan VUKOVICH-TRIBOUHARET
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-21 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: lograge
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: sentry-raven
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +186,7 @@ files:
172
186
  - app/controllers/eivo/concerns/resources.rb
173
187
  - app/controllers/eivo/status_controller.rb
174
188
  - bin/eivo
189
+ - config/initializers/logger.rb
175
190
  - config/initializers/sentry.rb
176
191
  - config/routes.rb
177
192
  - eivo-rails-api.gemspec
@@ -182,6 +197,7 @@ files:
182
197
  - lib/eivo-rails-api/environments/production.rb
183
198
  - lib/eivo-rails-api/environments/staging.rb
184
199
  - lib/eivo-rails-api/environments/test.rb
200
+ - lib/eivo-rails-api/formatter.rb
185
201
  - lib/generators/eivo/USAGE
186
202
  - lib/generators/eivo/install_generator.rb
187
203
  - lib/generators/eivo/templates/.env.example
@@ -217,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
233
  - !ruby/object:Gem::Version
218
234
  version: '0'
219
235
  requirements: []
220
- rubygems_version: 3.0.6
236
+ rubygems_version: 3.1.2
221
237
  signing_key:
222
238
  specification_version: 4
223
239
  summary: EIVO Rails API