Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
unless Rails.env.test?
Rails.application.config.hosts << AppHost.new.domain
end

View File

@@ -0,0 +1,4 @@
AnalyticsRuby = Segment::Analytics.new({
write_key: ENV.fetch("SEGMENT_SERVER_KEY", ""),
on_error: Proc.new { |_status, msg| print msg }
})

View File

@@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( contract_pdf.css )

View File

@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@@ -0,0 +1,6 @@
require_relative "../../lib/bootstrap_form_extensions"
# Include patches to `bootstrap_form` gem
class BootstrapForm::FormBuilder
prepend BootstrapFormExtensions
end

View File

@@ -0,0 +1 @@
require "brayniac_ai"

View File

@@ -0,0 +1,36 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
Rails.application.config.content_security_policy do |policy|
policy.default_src :self, :https, AppHost.new.domain_with_port, :unsafe_inline
policy.font_src :self, :https, :data
policy.img_src :self, :https, :data
policy.object_src :self
policy.script_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", :blob, :unsafe_eval
policy.media_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", :data, :blob
# policy.style_src :self, :https, :unsafe_inline
# If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
policy.connect_src :self, :https, "ws://#{AppHost.new.domain_with_port}", "wss://#{AppHost.new.domain_with_port}"
# Specify URI for violation reports
# policy.report_uri "/csp-violation-report-endpoint"
end
# If you are using UJS then enable automatic nonce generation
Rails.application.config.content_security_policy_nonce_generator = -> (request) do
# Use the same CSP nonce for Turbolinks requests
if request.env["HTTP_TURBOLINKS_REFERRER"].present?
request.env["HTTP_X_TURBOLINKS_NONCE"]
else
SecureRandom.base64(16)
end
end
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View File

@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@@ -0,0 +1,13 @@
# Be sure to restart your server when you modify this file.
# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
# Read more: https://github.com/cyu/rack-cors
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'https://stream.mux.com'
resource '*', headers: :any, methods: [:get, :post, :options]
end
end

View File

@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
# Filter base64 image strings from logs
Rails.application.config.filter_parameters += ['person_photo.io', 'guardian_photo.io', 'photos.io', 'signature', 'signature_base64']

View File

@@ -0,0 +1,9 @@
hubspot_api_key = ENV["HUBSPOT_API_KEY"]
hubspot_portal_id = ENV["HUBSPOT_PORTAL_ID"]
if hubspot_api_key.present? && hubspot_portal_id.present?
Hubspot.configure(
hapikey: hubspot_api_key,
portal_id: hubspot_portal_id
)
end

View File

@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@@ -0,0 +1,83 @@
require "jsonapi/rails"
JSONAPI::Rails.configure do |config|
# # Set a default serializable class mapping.
# config.jsonapi_class = Hash.new { |h, k|
# names = k.to_s.split('::')
# klass = names.pop
# h[k] = [*names, "Serializable#{klass}"].join('::').safe_constantize
# }
#
# # Set a default serializable class mapping for errors.
# config.jsonapi_errors_class = Hash.new { |h, k|
# names = k.to_s.split('::')
# klass = names.pop
# h[k] = [*names, "Serializable#{klass}"].join('::').safe_constantize
# }.tap { |h|
# h[:'ActiveModel::Errors'] = JSONAPI::Rails::SerializableActiveModelErrors
# h[:Hash] = JSONAPI::Rails::SerializableErrorHash
# }
#
# # Set a default JSON API object.
# config.jsonapi_object = {
# version: '1.0'
# }
#
# # Set default cache.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_cache = ->() { nil }
#
# # Uncomment the following to enable fragment caching. Make sure you
# # invalidate cache keys accordingly.
# config.jsonapi_cache = lambda {
# Rails.cache
# }
#
# # Set default exposures.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_expose = lambda {
# { url_helpers: ::Rails.application.routes.url_helpers }
# }
#
# # Set default fields.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_fields = ->() { nil }
#
# # Uncomment the following to have it default to the `fields` query
# # parameter.
# config.jsonapi_fields = lambda {
# fields_param = params.to_unsafe_hash.fetch(:fields, {})
# Hash[fields_param.map { |k, v| [k.to_sym, v.split(',').map!(&:to_sym)] }]
# }
#
# # Set default include.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_include = ->() { nil }
#
# # Uncomment the following to have it default to the `include` query
# # parameter.
# config.jsonapi_include = lambda {
# params[:include]
# }
#
# # Set default links.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_links = ->() { {} }
#
# # Set default meta.
# # A lambda/proc that will be eval'd in the controller context.
# config.jsonapi_meta = ->() { nil }
#
# # Set a default pagination scheme.
# config.jsonapi_pagination = ->(_) { {} }
#
# # Set a logger.
# config.logger = Logger.new(STDOUT)
#
# # Uncomment the following to disable logging.
if Rails.env.test?
# too chatty on the tests, but useful in other envs
# because of the possible deserialization problems
config.logger = Logger.new('/dev/null')
end
end

View File

@@ -0,0 +1,66 @@
require "knock/version"
require "knock/authenticable"
Knock.setup do |config|
## Expiration claim
## ----------------
##
## How long before a token is expired. If nil is provided, token will
## last forever.
##
## Default:
config.token_lifetime = 10.years
## Audience claim
## --------------
##
## Configure the audience claim to identify the recipients that the token
## is intended for.
##
## Default:
# config.token_audience = nil
## If using Auth0, uncomment the line below
# config.token_audience = -> { Rails.application.secrets.auth0_client_id }
## Signature algorithm
## -------------------
##
## Configure the algorithm used to encode the token
##
## Default:
# config.token_signature_algorithm = 'HS256'
## Signature key
## -------------
##
## Configure the key used to sign tokens.
##
## Default:
# config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
# Default does not work in production, other does not work in dev
# When combined, they become: working configuration!
config.token_secret_signature_key = -> {
Rails.application.secrets.secret_key_base || Rails.application.credentials.secret_key_base
}
## If using Auth0, uncomment the line below
# config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret }
## Public key
## ----------
##
## Configure the public key used to decode tokens, if required.
##
## Default:
# config.token_public_key = nil
## Exception Class
## ---------------
##
## Configure the exception to be used when user cannot be found.
##
## Default:
# config.not_found_exception_class_name = 'ActiveRecord::RecordNotFound'
end

View File

@@ -0,0 +1,2 @@
# Whitelist locales available for the application
I18n.available_locales = [:en, :es]

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@@ -0,0 +1,115 @@
# encoding : utf-8
MoneyRails.configure do |config|
# To set the default currency
#
# config.default_currency = :usd
# Set default bank object
#
# Example:
# config.default_bank = EuCentralBank.new
# Add exchange rates to current money bank object.
# (The conversion rate refers to one direction only)
#
# Example:
# config.add_rate "USD", "CAD", 1.24515
# config.add_rate "CAD", "USD", 0.803115
# To handle the inclusion of validations for monetized fields
# The default value is true
#
# config.include_validations = true
# Default ActiveRecord migration configuration values for columns:
#
# config.amount_column = { prefix: '', # column name prefix
# postfix: '_cents', # column name postfix
# column_name: nil, # full column name (overrides prefix, postfix and accessor name)
# type: :integer, # column type
# present: true, # column will be created
# null: false, # other options will be treated as column options
# default: 0
# }
#
# config.currency_column = { prefix: '',
# postfix: '_currency',
# column_name: nil,
# type: :string,
# present: true,
# null: false,
# default: 'USD'
# }
# Register a custom currency
#
# Example:
# config.register_currency = {
# priority: 1,
# iso_code: "EU4",
# name: "Euro with subunit of 4 digits",
# symbol: "€",
# symbol_first: true,
# subunit: "Subcent",
# subunit_to_unit: 10000,
# thousands_separator: ".",
# decimal_mark: ","
# }
# Specify a rounding mode
# Any one of:
#
# BigDecimal::ROUND_UP,
# BigDecimal::ROUND_DOWN,
# BigDecimal::ROUND_HALF_UP,
# BigDecimal::ROUND_HALF_DOWN,
# BigDecimal::ROUND_HALF_EVEN,
# BigDecimal::ROUND_CEILING,
# BigDecimal::ROUND_FLOOR
#
# set to BigDecimal::ROUND_HALF_EVEN by default
#
# config.rounding_mode = BigDecimal::ROUND_HALF_UP
# Set default money format globally.
# Default value is nil meaning "ignore this option".
# Example:
#
# config.default_format = {
# no_cents_if_whole: nil,
# symbol: nil,
# sign_before_symbol: nil
# }
# If you would like to use I18n localization (formatting depends on the
# locale):
# config.locale_backend = :i18n
#
# Example (using default localization from rails-i18n):
#
# I18n.locale = :en
# Money.new(10_000_00, 'USD').format # => $10,000.00
# I18n.locale = :es
# Money.new(10_000_00, 'USD').format # => $10.000,00
#
# For the legacy behaviour of "per currency" localization (formatting depends
# only on currency):
config.locale_backend = :currency
#
# Example:
# Money.new(10_000_00, 'USD').format # => $10,000.00
# Money.new(10_000_00, 'EUR').format # => €10.000,00
#
# In case you don't need localization and would like to use default values
# (can be redefined using config.default_format):
# config.locale_backend = nil
# Set default raise_error_on_money_parsing option
# It will be raise error if assigned different currency
# The default value is false
#
# Example:
# config.raise_error_on_money_parsing = false
end

View File

@@ -0,0 +1,4 @@
MuxRuby.configure do |config|
config.username = ENV['MUX_TOKEN_ID']
config.password = ENV['MUX_TOKEN_SECRET']
end

View File

@@ -0,0 +1,3 @@
if ENV["REDIS_URL"]
$redis = Redis.new(url: ENV["REDIS_URL"])
end

View File

@@ -0,0 +1,6 @@
if sentry_dsn = ENV['SENTRY_DSN']
Raven.configure do |config|
config.dsn = sentry_dsn
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
end
end

View File

@@ -0,0 +1 @@
WillPaginate.per_page = 15

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View File

@@ -0,0 +1,26 @@
require 'zoom'
unless Rails.env.test?
Zoom.configure do |c|
c.api_key = ENV['ZOOM_API_KEY']
c.api_secret = ENV['ZOOM_API_SECRET']
end
end
class Zoom::APIError < StandardError
attr_reader :status_code
def initialize(status_code)
super
@status_code = status_code
end
end
module RaiseErrorsWithCodes
def raise_if_error!(response)
if response&.[]('code') && (response['code'] >= 300 || response['code'] == 124)
raise Zoom::APIError.new(response['code']), response['message']
else
super
end
end
end
Zoom::Utils.singleton_class.send :prepend, RaiseErrorsWithCodes