-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
67 lines (59 loc) · 1.75 KB
/
app.rb
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'puma'
require 'roda'
require 'json'
require 'better_errors'
require 'logger'
require 'rbnacl'
require 'securerandom'
require 'base64'
require 'active_support'
require 'active_support/core_ext/date_time'
require 'active_support/core_ext/date'
require 'active_support/core_ext/time'
require 'active_support/core_ext/numeric'
require 'nokogiri'
require 'jwt'
require 'tilt/erubis'
require './models'
require './env.rb'
class App < Roda
plugin :default_headers,
'Content-Type' => 'text/html',
'Content-Security-Policy' => "default-src 'self' #{ENV['BASE_URL']} *.cloudflare.com *.fontawesome.com *.googleapis.com *.gstatic.com unpkg.com; style-src 'unsafe-inline' *.fontawesome.com *.googleapis.com *.gstatic.com unpkg.com #{ENV['BASE_URL']}; img-src *",
'Strict-Transport-Security' => 'max-age=160704400',
'X-Frame-Options' => 'deny',
'X-Content-Type-Options' => 'nosniff',
'X-XSS-Protection' => '1; mode=block'
plugin :environments
plugin :multi_route
plugin :render, :engine => 'erubis', :views => 'views'
plugin :static, ['/js', '/css']
plugin :flash
plugin :all_verbs
plugin :h
plugin :multi_route
plugin :not_found do
Nokogiri::HTML(File.open("public/404.html")).to_s
end
self.environment = :development
configure do
use Rack::Session::Cookie, :secret => ENV['SECRET']
use Rack::Session::Pool, :expire_after => 252000
end
configure :development do
use Rack::MethodOverride
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
end
configure :production do
end
Dir['./route/*.rb'].each { |f| require f }
Dir['./helpers/*.rb'].each { |f| require f }
Dir['./lib/*.rb'].each { |f| require f }
route do |r|
r.multi_route
r.root do
view 'index'
end
end
end