-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ru
More file actions
51 lines (40 loc) · 1.65 KB
/
config.ru
File metadata and controls
51 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
require 'dotenv/load' if File.exist?('.env')
require 'oj'
require 'iodine'
require 'rack/attack'
require 'rack/cors'
Iodine.threads = Integer(ENV.fetch('IODINE_THREADS', 4))
Iodine.workers = Integer(ENV.fetch('IODINE_WORKERS', 1))
PROPAY_VERSION = '1.0.0'
SUPPORTED_PLANS = %w[pro_monthly pro_annual enterprise].freeze
PIX_KEY_TYPES = %w[cpf cnpj email phone random].freeze
VALID_PROVIDERS = %w[openpix efi].freeze
require_relative 'config/database'
require_relative 'config/redis'
# Load order: models -> services -> jobs -> handlers
Dir[File.join(__dir__, 'app', 'models', '*.rb')].each { |f| require f }
Dir[File.join(__dir__, 'app', 'middleware', '*.rb')].each { |f| require f }
Dir[File.join(__dir__, 'app', 'providers', '*.rb')].each { |f| require f }
Dir[File.join(__dir__, 'app', 'services', '*.rb')].each { |f| require f }
Dir[File.join(__dir__, 'app', 'jobs', '*.rb')].each { |f| require f }
Dir[File.join(__dir__, 'app', 'handlers', '*.rb')].each { |f| require f }
Rack::Attack.throttle('propay/ip', limit: 30, period: 60, &:ip)
Rack::Attack.throttle('propay/user', limit: 10, period: 60) do |req|
req.env['propay.user_id']
end
GC.compact
require_relative 'app/propay_app'
CORS_ORIGINS = "#{ENV.fetch('CORS_ORIGINS', '')},https://arena-br.vercel.app,https://prostaff.gg"
.split(',').map(&:strip).reject(&:empty?).freeze
app = Rack::Cors.new(ProPayApp.freeze.app) do
allow do
origins(*CORS_ORIGINS)
resource '/v1/*',
headers: :any,
methods: %i[get post patch delete options],
expose: ['X-Request-Id'],
max_age: 600
end
end
run app