Sha256: b003293b16c8146b4d3f9e63599fca1a8a76777a9023d342399c59b1c4c31dec

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require "hanami"
require "rack/attack"

<% namespace do %>
  # Defines global application configuration.
  class App < Hanami::App
    Dry::Schema.load_extensions :monads
    Dry::Validation.load_extensions :monads

    config.actions.content_security_policy.then do |csp|
      csp[:manifest_src] = "'self'"
      csp[:script_src] += " 'unsafe-eval' 'unsafe-inline' https://unpkg.com/"
    end

    Rack::Attack.safelist("allow localhost") { |request| %w[127.0.0.1 ::1].include? request.ip }
    Rack::Attack.throttle("requests by IP", limit: 100, period: 60, &:ip)

    config.middleware.use Rack::Attack
    config.middleware.use Rack::Deflater
    config.middleware.use Rack::Static,
                          {root: "public", urls: %w[/icon.svg /manifest.webmanifest /stylesheets]}

    environment :development do
      # :nocov:
      config.logger.options[:colorize] = true

      config.logger = config.logger.instance.add_backend(
        colorize: false,
        stream: Hanami.app.root.join("log/development.log")
      )
    end
  end
<% end %>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanamismith-0.22.1 lib/hanamismith/templates/%project_name%/config/app.rb.erb
hanamismith-0.22.0 lib/hanamismith/templates/%project_name%/config/app.rb.erb
hanamismith-0.21.0 lib/hanamismith/templates/%project_name%/config/app.rb.erb
hanamismith-0.20.0 lib/hanamismith/templates/%project_name%/config/app.rb.erb
hanamismith-0.19.0 lib/hanamismith/templates/%project_name%/config/app.rb.erb