neeto-commons-backend 1.0.89
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintignore +14 -0
- data/.eslintrc.js +87 -0
- data/.husky/helpers/verify_neeto_audit.sh +18 -0
- data/.husky/pre-push +5 -0
- data/.neetoci/neetoci.yml +26 -0
- data/.prettierrc.js +15 -0
- data/.rubocop.yml +626 -0
- data/.ruby-version +1 -0
- data/.semaphore/semaphore.yml +32 -0
- data/.semaphore/staging-deploy.yml +23 -0
- data/Gemfile +92 -0
- data/Gemfile.lock +461 -0
- data/README.md +286 -0
- data/Rakefile +18 -0
- data/app/controllers/api/base_controller.rb +6 -0
- data/app/controllers/neeto_commons_backend/api/base_controller.rb +9 -0
- data/app/controllers/neeto_commons_backend/api/direct_uploads_controller.rb +57 -0
- data/app/controllers/neeto_commons_backend/app_versions_controller.rb +20 -0
- data/app/controllers/neeto_commons_backend/failures_controller.rb +29 -0
- data/app/controllers/neeto_commons_backend/health_check_controller.rb +9 -0
- data/app/controllers/neeto_commons_backend/well_knowns_controller.rb +13 -0
- data/app/mailers/neeto_commons_backend/application_mailer.rb +22 -0
- data/app/models/concerns/neeto_commons_backend/sluggable.rb +27 -0
- data/app/models/concerns/neeto_commons_backend/soft_deletable.rb +20 -0
- data/app/services/neeto_commons_backend/sample_data/common/admin_service.rb +26 -0
- data/app/services/neeto_commons_backend/sample_data/common/app_organization_service.rb +11 -0
- data/app/services/neeto_commons_backend/sample_data/common/base.rb +49 -0
- data/app/services/neeto_commons_backend/sample_data/common/database_cleanup_service.rb +13 -0
- data/app/services/neeto_commons_backend/sample_data/common/loader_service.rb +30 -0
- data/app/services/neeto_commons_backend/sample_data/common/neeto_team_members_service.rb +16 -0
- data/app/services/neeto_commons_backend/sample_data/common/organization_base.rb +36 -0
- data/app/services/neeto_commons_backend/sample_data/common/organization_service.rb +11 -0
- data/app/services/neeto_commons_backend/source_map_publish_service.rb +47 -0
- data/app/views/neeto_commons_backend/failures/show.html.erb +1 -0
- data/app/views/shared/_common.html.erb +8 -0
- data/app/views/shared/_neeto_engineering_replay_widget.html.erb +31 -0
- data/app/views/shared/_neeto_widget.html.erb +30 -0
- data/app/workers/neeto_commons_backend/base_workers/auth.rb +9 -0
- data/app/workers/neeto_commons_backend/base_workers/base.rb +52 -0
- data/app/workers/neeto_commons_backend/base_workers/default.rb +8 -0
- data/app/workers/neeto_commons_backend/base_workers/low.rb +9 -0
- data/app/workers/neeto_commons_backend/base_workers/urgent.rb +9 -0
- data/app/workers/neeto_commons_backend/purge_unattached_files_worker.rb +11 -0
- data/babel.config.js +47 -0
- data/bin/console +15 -0
- data/bin/rails +16 -0
- data/bin/setup +8 -0
- data/config/brakeman.ignore +52 -0
- data/config/locales/en.yml +5 -0
- data/docs/carriers/README.md +5 -0
- data/docs/controller_concerns/README.md +34 -0
- data/docs/controllers/README.md +27 -0
- data/docs/gemfiles/README.md +5 -0
- data/docs/helpers/README.md +21 -0
- data/docs/mailers/README.md +5 -0
- data/docs/model_concerns/README.md +39 -0
- data/docs/routes/README.md +44 -0
- data/docs/scripts/README.md +5 -0
- data/docs/semaphore/README.md +5 -0
- data/docs/services/README.md +23 -0
- data/docs/workers/README.md +32 -0
- data/docs/workflows/README.md +9 -0
- data/lib/Rakefile +4 -0
- data/lib/neeto-commons-backend.rb +62 -0
- data/lib/neeto_commons_backend/.circleci/config.yml +84 -0
- data/lib/neeto_commons_backend/.slugignore +17 -0
- data/lib/neeto_commons_backend/carriers/app_url_carrier.rb +71 -0
- data/lib/neeto_commons_backend/common_files/.bundler-version +1 -0
- data/lib/neeto_commons_backend/common_files/.editorconfig +10 -0
- data/lib/neeto_commons_backend/common_files/.erb-lint.yml +20 -0
- data/lib/neeto_commons_backend/common_files/.eslintignore +14 -0
- data/lib/neeto_commons_backend/common_files/.eslintrc.js +2 -0
- data/lib/neeto_commons_backend/common_files/.gitignore +132 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/lint_staged.sh +5 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/prevent_conflict_markers.sh +35 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/prevent_pushing_to_main.sh +24 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/verify_neeto_audit.sh +17 -0
- data/lib/neeto_commons_backend/common_files/.husky/pre-commit +9 -0
- data/lib/neeto_commons_backend/common_files/.husky/pre-push +7 -0
- data/lib/neeto_commons_backend/common_files/.node-version +1 -0
- data/lib/neeto_commons_backend/common_files/.nvmrc +1 -0
- data/lib/neeto_commons_backend/common_files/.postcssrc.yml +6 -0
- data/lib/neeto_commons_backend/common_files/.prettierrc.js +1 -0
- data/lib/neeto_commons_backend/common_files/.rubocop.yml +625 -0
- data/lib/neeto_commons_backend/common_files/.ruby-version +1 -0
- data/lib/neeto_commons_backend/common_files/.semaphore/commands/run_eslint_on_modified_files.sh +5 -0
- data/lib/neeto_commons_backend/common_files/.vscode/extensions.json +10 -0
- data/lib/neeto_commons_backend/common_files/.vscode/settings.json +21 -0
- data/lib/neeto_commons_backend/common_files/Dockerfile.dev +50 -0
- data/lib/neeto_commons_backend/common_files/app/javascript/jsconfig.json +62 -0
- data/lib/neeto_commons_backend/common_files/app/javascript/src/types.d.ts +36 -0
- data/lib/neeto_commons_backend/common_files/babel.config.js +1 -0
- data/lib/neeto_commons_backend/common_files/bin/bundle +5 -0
- data/lib/neeto_commons_backend/common_files/bin/rails +6 -0
- data/lib/neeto_commons_backend/common_files/bin/rake +6 -0
- data/lib/neeto_commons_backend/common_files/bin/setup +40 -0
- data/lib/neeto_commons_backend/common_files/bin/update +33 -0
- data/lib/neeto_commons_backend/common_files/bin/webpacker +17 -0
- data/lib/neeto_commons_backend/common_files/bin/webpacker-dev-server +17 -0
- data/lib/neeto_commons_backend/common_files/bin/yarn +19 -0
- data/lib/neeto_commons_backend/common_files/cypress-tests/.eslintrc.js +57 -0
- data/lib/neeto_commons_backend/common_files/cypress-tests/cypress/plugins/index.js +63 -0
- data/lib/neeto_commons_backend/common_files/github/workflows/auto_update_prs_with_latest_master.yml +21 -0
- data/lib/neeto_commons_backend/common_files/neeto_gems/github/workflows/bump_version.yml +51 -0
- data/lib/neeto_commons_backend/common_files/newrelic.yml +31 -0
- data/lib/neeto_commons_backend/common_files/package-common.json +119 -0
- data/lib/neeto_commons_backend/common_files/roles.yml +34 -0
- data/lib/neeto_commons_backend/common_files/semaphore/semaphore.yml +58 -0
- data/lib/neeto_commons_backend/common_files/sitemap.xml +15 -0
- data/lib/neeto_commons_backend/common_files/test/support/assertion_support.rb +9 -0
- data/lib/neeto_commons_backend/common_files/webpacker.yml +90 -0
- data/lib/neeto_commons_backend/config/secrets.yml +169 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_exceptions.rb +83 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_helpers.rb +9 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_responders.rb +33 -0
- data/lib/neeto_commons_backend/controllers/concerns/authenticatable.rb +51 -0
- data/lib/neeto_commons_backend/controllers/concerns/honeybadger_context.rb +17 -0
- data/lib/neeto_commons_backend/controllers/concerns/store_user_location.rb +23 -0
- data/lib/neeto_commons_backend/cypress/cypress.review.json +13 -0
- data/lib/neeto_commons_backend/cypress/jsconfig.json +17 -0
- data/lib/neeto_commons_backend/cypress/package.json +51 -0
- data/lib/neeto_commons_backend/cypress/resolve.js +16 -0
- data/lib/neeto_commons_backend/cypress/webpack.config.js +21 -0
- data/lib/neeto_commons_backend/engine.rb +6 -0
- data/lib/neeto_commons_backend/environments/application.rb +33 -0
- data/lib/neeto_commons_backend/environments/development.rb +46 -0
- data/lib/neeto_commons_backend/environments/heroku.rb +35 -0
- data/lib/neeto_commons_backend/environments/production.rb +45 -0
- data/lib/neeto_commons_backend/environments/staging.rb +43 -0
- data/lib/neeto_commons_backend/environments/test.rb +29 -0
- data/lib/neeto_commons_backend/gemfiles/Gemfile.common.rb +240 -0
- data/lib/neeto_commons_backend/helpers/auth_server_api.rb +92 -0
- data/lib/neeto_commons_backend/helpers/favicon.rb +18 -0
- data/lib/neeto_commons_backend/helpers/global_props.rb +76 -0
- data/lib/neeto_commons_backend/helpers/neeto_widget_helper.rb +19 -0
- data/lib/neeto_commons_backend/helpers/test_helper.rb +90 -0
- data/lib/neeto_commons_backend/initializers/_enable_extension_hack.rb +32 -0
- data/lib/neeto_commons_backend/initializers/assets.rb +11 -0
- data/lib/neeto_commons_backend/initializers/bullet.rb +26 -0
- data/lib/neeto_commons_backend/initializers/cache_store.rb +27 -0
- data/lib/neeto_commons_backend/initializers/common.rb +33 -0
- data/lib/neeto_commons_backend/initializers/cookies_serializer.rb +11 -0
- data/lib/neeto_commons_backend/initializers/cors.rb +16 -0
- data/lib/neeto_commons_backend/initializers/database_cleaner.rb +11 -0
- data/lib/neeto_commons_backend/initializers/datetime.rb +14 -0
- data/lib/neeto_commons_backend/initializers/email_setup.rb +25 -0
- data/lib/neeto_commons_backend/initializers/filter_parameter_logging.rb +11 -0
- data/lib/neeto_commons_backend/initializers/honeybadger.rb +23 -0
- data/lib/neeto_commons_backend/initializers/kaminari_config.rb +13 -0
- data/lib/neeto_commons_backend/initializers/mime_types.rb +12 -0
- data/lib/neeto_commons_backend/initializers/mini_profiler.rb +14 -0
- data/lib/neeto_commons_backend/initializers/neeto_email_prefixer.rb +40 -0
- data/lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb +35 -0
- data/lib/neeto_commons_backend/initializers/post_compilation.rb +17 -0
- data/lib/neeto_commons_backend/initializers/rack_attack.rb +38 -0
- data/lib/neeto_commons_backend/initializers/rack_deflater.rb +11 -0
- data/lib/neeto_commons_backend/initializers/rack_timeout.rb +15 -0
- data/lib/neeto_commons_backend/initializers/rails_email_preview.rb +21 -0
- data/lib/neeto_commons_backend/initializers/redis_client_patch.rb +18 -0
- data/lib/neeto_commons_backend/initializers/remove_backtrace_silencers.rb +11 -0
- data/lib/neeto_commons_backend/initializers/session_store.rb +21 -0
- data/lib/neeto_commons_backend/initializers/shared_redis.rb +13 -0
- data/lib/neeto_commons_backend/initializers/sidekiq.rb +46 -0
- data/lib/neeto_commons_backend/initializers/strong_migrations.rb +13 -0
- data/lib/neeto_commons_backend/initializers/wrap_parameters.rb +13 -0
- data/lib/neeto_commons_backend/models/concerns/devise_validator.rb +19 -0
- data/lib/neeto_commons_backend/railtie.rb +20 -0
- data/lib/neeto_commons_backend/routes/catch_all.rb +9 -0
- data/lib/neeto_commons_backend/routes/devise.rb +16 -0
- data/lib/neeto_commons_backend/routes/direct_uploads.rb +9 -0
- data/lib/neeto_commons_backend/routes/draw.rb +29 -0
- data/lib/neeto_commons_backend/routes/email_previews.rb +5 -0
- data/lib/neeto_commons_backend/routes/errors.rb +7 -0
- data/lib/neeto_commons_backend/routes/health.rb +8 -0
- data/lib/neeto_commons_backend/routes/letter_opener.rb +5 -0
- data/lib/neeto_commons_backend/routes/sidekiq.rb +22 -0
- data/lib/neeto_commons_backend/routes/well_knowns.rb +10 -0
- data/lib/neeto_commons_backend/scripts/sync_with_wheel.sh +54 -0
- data/lib/neeto_commons_backend/secrets_management.rb +41 -0
- data/lib/neeto_commons_backend/services/custom_domain_service.rb +40 -0
- data/lib/neeto_commons_backend/tasks/assets.rake +27 -0
- data/lib/neeto_commons_backend/tasks/before_assets_precompile.rake +13 -0
- data/lib/neeto_commons_backend/tasks/simplecov_coverage.rake +25 -0
- data/lib/neeto_commons_backend/version.rb +5 -0
- data/neeto-commons-backend.gemspec +52 -0
- data/package.json +31 -0
- data/yarn.lock +2530 -0
- metadata +497 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "securerandom"
|
4
|
+
|
5
|
+
module NeetoCommonsBackend
|
6
|
+
module SampleData
|
7
|
+
module Common
|
8
|
+
class OrganizationBase < Common::Base
|
9
|
+
attr_reader :organization_name, :organization
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@organization_name = self.class::ORGANIZATION_NAME
|
13
|
+
end
|
14
|
+
|
15
|
+
def process!
|
16
|
+
create_organization!
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def create_organization!
|
22
|
+
auth_app = app_secrets.auth_app
|
23
|
+
|
24
|
+
@organization = Organization.create! \
|
25
|
+
name: organization_name,
|
26
|
+
subdomain: organization_name.parameterize,
|
27
|
+
auth_app_url: auth_app[:url],
|
28
|
+
auth_app_id: auth_app[:id],
|
29
|
+
auth_app_secret: auth_app[:secret],
|
30
|
+
api_key: SecureRandom.alphanumeric,
|
31
|
+
widget_api_key: SecureRandom.alphanumeric
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Service to upload SourceMap files to Honeybadger during Heroku deployment
|
4
|
+
# process, once the bin/webpack step is completed.
|
5
|
+
module NeetoCommonsBackend
|
6
|
+
class SourceMapPublishService
|
7
|
+
def process!
|
8
|
+
upload_all_js_source_maps
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def upload_all_js_source_maps
|
14
|
+
file = File.open("public/packs/manifest.json")
|
15
|
+
data = JSON.parse(file.read)
|
16
|
+
file.close
|
17
|
+
|
18
|
+
data.entries
|
19
|
+
.filter { |file_name, _file_url| file_name.end_with?(".js") }
|
20
|
+
.map { |_file_name, file_url| file_url }
|
21
|
+
.each(&method(:upload_source_map))
|
22
|
+
end
|
23
|
+
|
24
|
+
def upload_source_map(file_url)
|
25
|
+
relative_path = "public#{URI.parse(file_url).path}"
|
26
|
+
minified_url = "https://*#{file_url}"
|
27
|
+
Rails.logger.debug(
|
28
|
+
revision: ENV["HEROKU_SLUG_COMMIT"],
|
29
|
+
minified_url:,
|
30
|
+
source_map: "#{relative_path}.map",
|
31
|
+
minified_file: relative_path
|
32
|
+
)
|
33
|
+
begin
|
34
|
+
Rails.logger.debug `
|
35
|
+
curl https://api.honeybadger.io/v1/source_maps \
|
36
|
+
-F api_key=#{ENV["HONEYBADGER_JS_API_KEY"] || ENV["HONEYBADGER_API_KEY"]} \
|
37
|
+
-F revision=#{ENV["HEROKU_SLUG_COMMIT"]} \
|
38
|
+
-F minified_url=#{minified_url} \
|
39
|
+
-F source_map=@#{relative_path}.map \
|
40
|
+
-F minified_file=@#{relative_path}
|
41
|
+
`
|
42
|
+
rescue RestClient::ExceptionWithResponse => e
|
43
|
+
Rails.logger.debug e.response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= react_component("Error", { error_status_code: @status_code }, { class: "root-container" }) %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2
|
+
<title><%= content_for?(:title) ? yield(:title) : Rails.application.secrets.app_default_title %></title>
|
3
|
+
<%= NeetoCommonsBackend::Helpers.favicon(@organization) %>
|
4
|
+
<%= csrf_meta_tags %>
|
5
|
+
<%= csp_meta_tag %>
|
6
|
+
<%= stylesheet_pack_tag "application" %>
|
7
|
+
<%= render "shared/neeto_widget" %>
|
8
|
+
<%= render "shared/neeto_engineering_replay_widget" %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% unless Rails.application.secrets.neeto_engineering_widget_api_key.nil? %>
|
2
|
+
<script defer>
|
3
|
+
// this script will just load neeto-replay-widget to upload all the recordings
|
4
|
+
// of neeto products under neeto-engineering organization of neetoreplay
|
5
|
+
// staging: neeto-engineering.neetoreplay.net
|
6
|
+
// production: neeto-engineering.neetoreplay.com
|
7
|
+
|
8
|
+
<% if current_user.present? %>
|
9
|
+
window.NeetoWidgetUserIdentity = {
|
10
|
+
email: "<%= current_user.email %>"
|
11
|
+
}
|
12
|
+
window.NeetoReplayWidgetSessionContext = {
|
13
|
+
user_id: "<%= current_user.id %>",
|
14
|
+
sign_in_count: "<%= current_user.sign_in_count %>",
|
15
|
+
name: ["<%= current_user.first_name %>", "<%= current_user.last_name %>"]
|
16
|
+
}
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
function handleEngineeringReplayWidgetScriptOnLoad() {
|
20
|
+
embedNeetoWidget({
|
21
|
+
environment: "<%= NeetoCommonsBackend::Helpers.get_neeto_widget_environment %>",
|
22
|
+
apiKey: "<%= Rails.application.secrets.neeto_engineering_widget_api_key %>",
|
23
|
+
neetoChangelogOptions: {
|
24
|
+
elementId: "neetochangelog-trigger",
|
25
|
+
},
|
26
|
+
});
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
|
30
|
+
<script src="<%= NeetoCommonsBackend::Helpers.build_neeto_widget_script_url %>" onload="handleEngineeringReplayWidgetScriptOnLoad()"></script>
|
31
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<% unless Rails.application.secrets.widget_api_key.nil? %>
|
2
|
+
<script defer>
|
3
|
+
<% if current_user.present? %>
|
4
|
+
window.NeetoWidgetUserIdentity = {
|
5
|
+
email: "<%= current_user.email %>"
|
6
|
+
}
|
7
|
+
window.NeetoReplayWidgetSessionContext = {
|
8
|
+
user_id: "<%= current_user.id %>",
|
9
|
+
sign_in_count: "<%= current_user.sign_in_count %>",
|
10
|
+
name: ["<%= current_user.first_name %>", "<%= current_user.last_name %>"]
|
11
|
+
}
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
function handleWidgetScriptOnLoad() {
|
15
|
+
window.NeetoChat = {
|
16
|
+
visibleOnMount: false,
|
17
|
+
triggerAction: "hide"
|
18
|
+
}
|
19
|
+
embedNeetoWidget({
|
20
|
+
environment: "<%= NeetoCommonsBackend::Helpers.get_neeto_widget_environment %>",
|
21
|
+
apiKey: "<%= Rails.application.secrets.widget_api_key %>",
|
22
|
+
neetoChangelogOptions: {
|
23
|
+
elementId: "neetochangelog-trigger",
|
24
|
+
},
|
25
|
+
});
|
26
|
+
}
|
27
|
+
</script>
|
28
|
+
|
29
|
+
<script src="<%= NeetoCommonsBackend::Helpers.build_neeto_widget_script_url %>" onload="handleWidgetScriptOnLoad()"></script>
|
30
|
+
<% end %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module BaseWorkers
|
5
|
+
class Base
|
6
|
+
include Sidekiq::Worker
|
7
|
+
sidekiq_retries_exhausted do |message, exception|
|
8
|
+
Sidekiq.logger.warn "Failed #{message['class']} with #{message['args']}: #{message['error_message']}"
|
9
|
+
context = { class: message["class"], args: message["args"], error_message: message["error_message"] }
|
10
|
+
Honeybadger.notify(exception, context:)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.perform_unique_async(*arguments)
|
14
|
+
self.delete_matched(name, arguments)
|
15
|
+
|
16
|
+
self.perform_async(arguments)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.perform_unique_in(t, *arguments)
|
20
|
+
self.delete_matched(name, arguments)
|
21
|
+
|
22
|
+
self.perform_in(t, arguments)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.perform_unique_at(t, *arguments)
|
26
|
+
self.delete_matched(name, arguments)
|
27
|
+
|
28
|
+
self.perform_at(t, arguments)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.delete_matched(worker_name, arguments)
|
32
|
+
set = Sidekiq::ScheduledSet.new
|
33
|
+
|
34
|
+
set = if arguments.is_a?(Array) && arguments.first.is_a?(String)
|
35
|
+
set.scan arguments.first
|
36
|
+
elsif arguments.is_a?(String)
|
37
|
+
set.scan arguments
|
38
|
+
else
|
39
|
+
set.scan worker_name
|
40
|
+
end
|
41
|
+
|
42
|
+
set.each do |job|
|
43
|
+
job.delete if job.display_class == worker_name && job.args == [arguments]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def perform(*arguments)
|
48
|
+
Honeybadger.context(job_name: self.class.name, app_name: Rails.application.engine_name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
class PurgeUnattachedFilesWorker < NeetoCommonsBackend::BaseWorkers::Low
|
5
|
+
def perform
|
6
|
+
# ActiveStorage::Blob.unattached.where(
|
7
|
+
# "active_storage_blobs.created_at <= ?", 1.week.ago
|
8
|
+
# ).find_each(&:purge_later)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/babel.config.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module.exports = function (api) {
|
2
|
+
var validEnv = ["development", "test", "production"];
|
3
|
+
var currentEnv = api.env();
|
4
|
+
var isDevelopmentEnv = api.env("development");
|
5
|
+
var isProductionEnv = api.env("production");
|
6
|
+
var isTestEnv = api.env("test");
|
7
|
+
|
8
|
+
if (!validEnv.includes(currentEnv)) {
|
9
|
+
throw new Error(
|
10
|
+
"Please specify a valid `NODE_ENV` or " +
|
11
|
+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
|
12
|
+
'"test", and "production". Instead, received: ' +
|
13
|
+
JSON.stringify(currentEnv) +
|
14
|
+
"."
|
15
|
+
);
|
16
|
+
}
|
17
|
+
|
18
|
+
return {
|
19
|
+
presets: [
|
20
|
+
isTestEnv && [
|
21
|
+
"@babel/preset-env",
|
22
|
+
{
|
23
|
+
targets: { node: "current" },
|
24
|
+
modules: "commonjs",
|
25
|
+
},
|
26
|
+
"@babel/preset-react",
|
27
|
+
],
|
28
|
+
(isProductionEnv || isDevelopmentEnv) && [
|
29
|
+
"@babel/preset-env",
|
30
|
+
{
|
31
|
+
forceAllTransforms: true,
|
32
|
+
useBuiltIns: "entry",
|
33
|
+
corejs: 3,
|
34
|
+
modules: false,
|
35
|
+
exclude: ["transform-typeof-symbol"],
|
36
|
+
},
|
37
|
+
],
|
38
|
+
[
|
39
|
+
"@babel/preset-react",
|
40
|
+
{
|
41
|
+
development: isDevelopmentEnv || isTestEnv,
|
42
|
+
useBuiltIns: true,
|
43
|
+
},
|
44
|
+
],
|
45
|
+
].filter(Boolean),
|
46
|
+
};
|
47
|
+
};
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "neeto-commons-backend"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/rails
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
5
|
+
# installed from the root of your application.
|
6
|
+
|
7
|
+
ENGINE_ROOT = File.expand_path("..", __dir__)
|
8
|
+
ENGINE_PATH = File.expand_path("../lib/neeto_commons_backend/engine", __dir__)
|
9
|
+
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
|
10
|
+
|
11
|
+
# Set up gems listed in the Gemfile.
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
13
|
+
require "bundler/setup" if File.exist?(ENV.fetch("BUNDLE_GEMFILE", nil))
|
14
|
+
|
15
|
+
require "rails/all"
|
16
|
+
require "rails/engine/commands"
|
data/bin/setup
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"ignored_warnings": [
|
3
|
+
{
|
4
|
+
"warning_type": "Command Injection",
|
5
|
+
"warning_code": 14,
|
6
|
+
"fingerprint": "fbce6d49d56c9753c938428929aad9af6c63832c74d702cc8283d075bcb7ffd2",
|
7
|
+
"check_name": "Execute",
|
8
|
+
"message": "Possible command injection",
|
9
|
+
"file": "app/services/neeto_commons_backend/source_map_publish_service.rb",
|
10
|
+
"line": 35,
|
11
|
+
"link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
|
12
|
+
"code": "`\n curl https://api.honeybadger.io/v1/source_maps -F api_key=#{(ENV[\"HONEYBADGER_JS_API_KEY\"] or ENV[\"HONEYBADGER_API_KEY\"])} -F revision=#{ENV[\"HEROKU_SLUG_COMMIT\"]} -F minified_url=#{file_url} -F source_map=@#{\"public#{URI.parse(file_url).path}\"}.map -F minified_file=@#{\"public#{URI.parse(file_url).path}\"}\n `",
|
13
|
+
"render_path": null,
|
14
|
+
"location": {
|
15
|
+
"type": "method",
|
16
|
+
"class": "NeetoCommonsBackend::SourceMapPublishService",
|
17
|
+
"method": "upload_source_map"
|
18
|
+
},
|
19
|
+
"user_input": "ENV[\"HONEYBADGER_JS_API_KEY\"]",
|
20
|
+
"confidence": "Medium",
|
21
|
+
"cwe_id": [
|
22
|
+
77
|
23
|
+
],
|
24
|
+
"note": "Since, environment variables are defined in the backend or in the server, it is safe to assume that this cannot be exploited vis Command Injection"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"warning_type": "SQL Injection",
|
28
|
+
"warning_code": 0,
|
29
|
+
"fingerprint": "fe92186233531a732a25599e4483f19d65481552ef7b10c3e8343dc52332457f",
|
30
|
+
"check_name": "SQL",
|
31
|
+
"message": "Possible SQL injection",
|
32
|
+
"file": "app/models/concerns/neeto_commons_backend/sluggable.rb",
|
33
|
+
"line": 14,
|
34
|
+
"link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
|
35
|
+
"code": "(relation or self.class).where(\"#{slug_field} ~ ?\", \"^#{(\"untitled\" or self.send(value_field).parameterize)}$|^#{(\"untitled\" or self.send(value_field).parameterize)}-[0-9]+$\")",
|
36
|
+
"render_path": null,
|
37
|
+
"location": {
|
38
|
+
"type": "method",
|
39
|
+
"class": "NeetoCommonsBackend::Sluggable",
|
40
|
+
"method": "generate_slug"
|
41
|
+
},
|
42
|
+
"user_input": "slug_field",
|
43
|
+
"confidence": "Weak",
|
44
|
+
"cwe_id": [
|
45
|
+
89
|
46
|
+
],
|
47
|
+
"note": "slug_field is defined in the backend. Hence, safe to assume this code is not vulnerable to SQL injection."
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"updated": "2023-03-24 11:39:52 +0530",
|
51
|
+
"brakeman_version": "5.4.1"
|
52
|
+
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Carriers
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::AppUrlCarrier](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/carriers/app_url_carrier.rb)
|
4
|
+
|
5
|
+
This carrier contain methods for getting different application urls (app url, root url, websocket url).
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Model concerns
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::ApiHelpers](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/api_helpers.rb)
|
4
|
+
|
5
|
+
This concern adds API helper method i.e. `full_messages_with_keys_for` to the controllers.
|
6
|
+
|
7
|
+
- #### [NeetoCommonsBackend::ApiExceptions](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/api_exceptions.rb)
|
8
|
+
|
9
|
+
This concern handles all the API exceptions and errors. This concern also logs errors to Honeybadger.
|
10
|
+
|
11
|
+
- #### [NeetoCommonsBackend::ApiResponders](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/api_responders.rb)
|
12
|
+
|
13
|
+
This concern adds API responder methods to the controller. Available methods are as follows:
|
14
|
+
|
15
|
+
1. `render_message`
|
16
|
+
2. `render_success`
|
17
|
+
3. `render_error`
|
18
|
+
4. `render_notice`
|
19
|
+
5. `render_json`
|
20
|
+
6. `respond_with_error` (will be deprecated)
|
21
|
+
7. `respond_with_success` (will be deprecated)
|
22
|
+
8. `respond_with_json` (will be deprecated)
|
23
|
+
|
24
|
+
- #### [NeetoCommonsBackend::HoneybadgerContext](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/honeybadger_context.rb)
|
25
|
+
|
26
|
+
This concern initializes the Honeybadger context for the current user.
|
27
|
+
|
28
|
+
- #### [NeetoCommonsBackend::Authenticatable](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/authenticatable.rb)
|
29
|
+
|
30
|
+
This concern authenticates the `curent_user` using auth token.
|
31
|
+
|
32
|
+
- #### [NeetoCommonsBackend::StoreUserLocation](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/store_user_location.rb)
|
33
|
+
|
34
|
+
This concern stores the provided location.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Controllers
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::Api::BaseController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/api/base_controller.rb)
|
4
|
+
|
5
|
+
This controller contain common [authentication logic](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/controllers/concerns/authenticatable.rb) used by neeto products. You can inherit your base controller from this controller.
|
6
|
+
|
7
|
+
- #### [NeetoCommonsBackend::Api::DirectUploadsController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/app_versions_controller.rb)
|
8
|
+
|
9
|
+
This controller is used for creating, updating and deleting files using ActiveStorage.
|
10
|
+
|
11
|
+
- #### [NeetoCommonsBackend::AppVersionsController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/app_versions_controller.rb)
|
12
|
+
|
13
|
+
This controller returns the different app versions used by the mobile application.
|
14
|
+
|
15
|
+
- #### [NeetoCommonsBackend::FailuresController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/failures_controller.rb)
|
16
|
+
|
17
|
+
This controller catches all the failed API requests and logs them to Honeybadger.
|
18
|
+
|
19
|
+
- #### [NeetoCommonsBackend::HealthCheckController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/health_check_controller.rb)
|
20
|
+
|
21
|
+
This controller is used to verify the app server is up and running.
|
22
|
+
|
23
|
+
- #### [NeetoCommonsBackend::WellKnownsController](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/well_knowns_controller.rb)
|
24
|
+
|
25
|
+
This controller logs and shows the failed request status code and error.
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Common Gemfile
|
2
|
+
|
3
|
+
- #### [Gemfile.common.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/gemfiles/Gemfile.common.rb)
|
4
|
+
|
5
|
+
This is the common `Gemfile` across all the neeto products consisting all the common gem dependencies. Neeto gems version in all the products is also managed using this file.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Helpers
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::Helpers::AuthServerApi](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/helpers/auth_server_api.rb)
|
4
|
+
|
5
|
+
It helps in creating requests to auth server.
|
6
|
+
|
7
|
+
- #### [NeetoCommonsBackend::Helpers.favicon](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/helpers/favicon.rb)
|
8
|
+
|
9
|
+
This helper setup the favicon icon.
|
10
|
+
|
11
|
+
- #### [NeetoCommonsBackend::Helpers.common_client_props](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/helpers/global_props.rb)
|
12
|
+
|
13
|
+
This helper defines the commons client props like organization details, user details, neeto data, app details, Honeybadger details, env, permissions etc.
|
14
|
+
|
15
|
+
- #### [NeetoCommonsBackend::Helpers.build_neeto_widget_script_url](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/helpers/neeto_widget_helper.rb)
|
16
|
+
|
17
|
+
This helper adds the neeto widget script url according to environment.
|
18
|
+
|
19
|
+
- #### [NeetoCommonsBackend::TestHelper.setup](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/helpers/test_helper.rb)
|
20
|
+
|
21
|
+
This helper setup the simplecov config, minitest reporters config and common stubs for the tests.
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Mailers
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::ApplicationMailer](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/mailers/neeto_commons_backend/application_mailer.rb)
|
4
|
+
|
5
|
+
This application mailer contain common mailer logic used across the neeto product. You can inherit your host application mailer from this mailer.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Model concerns
|
2
|
+
|
3
|
+
- #### [NeetoCommonsBackend::Sluggable](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/models/concerns/neeto_commons_backend/sluggable.rb)
|
4
|
+
|
5
|
+
This concern contain methods for managing the slugs. Please include the concern in the model where you want to manage the slugs.
|
6
|
+
|
7
|
+
**Methods Available**
|
8
|
+
|
9
|
+
1. ##### generate_slug
|
10
|
+
This method can be used for generating new slug.
|
11
|
+
For example:
|
12
|
+
|
13
|
+
```rb
|
14
|
+
generate_slug(:title, :slug, organization.articles, title.blank?)
|
15
|
+
```
|
16
|
+
|
17
|
+
- #### [NeetoCommonsBackend::SoftDeletable](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/models/concerns/neeto_commons_backend/soft_deletable.rb)
|
18
|
+
|
19
|
+
This concern adds logic for soft deletion of records.
|
20
|
+
|
21
|
+
**Methods Available**
|
22
|
+
|
23
|
+
1. ##### `destroy`
|
24
|
+
This method can be used to soft delete a record:
|
25
|
+
|
26
|
+
```rb
|
27
|
+
oliver_user_object.destroy
|
28
|
+
```
|
29
|
+
|
30
|
+
2. ##### `really_destroy`
|
31
|
+
This method can be used to delete the record from table itself:
|
32
|
+
|
33
|
+
```rb
|
34
|
+
oliver_user_object.really_destroy
|
35
|
+
```
|
36
|
+
|
37
|
+
- #### [NeetoCommonsBackend::DeviseValidator](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/models/concerns/devise_validator.rb)
|
38
|
+
|
39
|
+
This concern adds validations to the email and password fields.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Routes
|
2
|
+
|
3
|
+
- #### [catch_all.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/catch_all.rb)
|
4
|
+
|
5
|
+
This API catches all the routes and redirects to [failures#show](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/failures_controller.rb#L7) action.
|
6
|
+
|
7
|
+
- #### [devise.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/devise.rb)
|
8
|
+
|
9
|
+
This API adds all the authorization related routes.
|
10
|
+
|
11
|
+
- #### [direct_uploads.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/direct_uploads.rb)
|
12
|
+
|
13
|
+
This API adds route for `/direct_uploads`.
|
14
|
+
|
15
|
+
- #### [draw.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/draw.rb)
|
16
|
+
|
17
|
+
This file helps in adding all the commons, neeto and basic routes from different files.
|
18
|
+
|
19
|
+
|
20
|
+
- #### [email_previews.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/email_previews.rb)
|
21
|
+
|
22
|
+
This API mounts the `RailsEmailPreview::Engine` for `/emails` route.
|
23
|
+
|
24
|
+
- #### [errors.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/errors.rb)
|
25
|
+
|
26
|
+
This API matches the `"/:status_code"` route and redirects to [failures#show](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/failures_controller.rb#L7) action.
|
27
|
+
|
28
|
+
- #### [health.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/health.rb)
|
29
|
+
|
30
|
+
This API adds routes for `/health_check` and `/app_version`.
|
31
|
+
|
32
|
+
- #### [letter_opener.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/letter_opener.rb)
|
33
|
+
|
34
|
+
This API mounts `LetterOpenerWeb::Engine` for `/mailbox` route.
|
35
|
+
|
36
|
+
|
37
|
+
- #### [sidekiq.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/sidekiq.rb)
|
38
|
+
|
39
|
+
This API adds the routes for `Sidekiq::Web`.
|
40
|
+
|
41
|
+
- #### [well_knowns.rb](https://github.com/bigbinary/neeto-commons-backend/blob/main/lib/neeto_commons_backend/routes/well_knowns.rb)
|
42
|
+
|
43
|
+
This API add the `/assetlinks` and `/apple-app-site-association` routes for [well_knowns_controller](https://github.com/bigbinary/neeto-commons-backend/blob/main/app/controllers/neeto_commons_backend/well_knowns_controller.rb).
|
44
|
+
|