# Hanami v2.0.0.alpha2 app template feedback

**URL:** <https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606>\
**Category:** proposals\
**Created:** [May 6, 2021, 12:06pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606 "2021-05-06T12:06:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:06pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/1 "2021-05-06T12:06:49Z")

</div>

With Hanami [v2.0.0.alpha2 release](https://hanamirb.org/blog/2021/05/04/announcing-hanami-200alpha2/), we built an [application template](https://github.com/hanami/hanami-2-application-template) to share with the Community how an app built with Hanami would look like.

👉We decided that the goal for v2.0.0.alpha3 will be to finalize the application template code.  
That means to cleanup application template code, improve it with features, but also extract parts of it in Hanami gems.

* * *

ℹ This forum topic should be used to share feedback regarding the application template, so we can openly decide which work shall be done for alpha3.

Each decision will result into a Trello ticket, which will be taken from any of us into the development process.

For each implemented ticket (into Hanami gems), we must update the application template to reflect the changes from the framework.

* * *

📝 Please provide your feedback here.

⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠  
**In order to make feedback process easier, please create a separated comment for each file in the application template that you would see to be changed. Use threads to discuss each feedback.**  
⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:07pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/2 "2021-05-06T12:07:30Z")

</div>

`config/boot/assets.rb`

- must be ported to `hanami-assets`

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:08pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/3 "2021-05-06T12:08:40Z")

</div>

Consider to rename `Hanami.application.register_bootable` into `Hanami.container.register`, or `Hanami.application.container.register`.

Similarly we should expose container resolved keys via `Hanami.container.keys`.

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:09pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/4 "2021-05-06T12:09:05Z")

</div>

`config/boot/persistence.rb`

- must be ported to `hanami`

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:10pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/5 "2021-05-06T12:10:01Z")

</div>

`config/puma.rb`

- `PORT` must be `2300`
- Consider to introduce `stop` block in `Dry::System.register_bootable` so the informations to tear down a component are local to it:

```auto
Hanami.container.register :persistence, namespace: true do |container|
  init { ... }
  start { ... }

  stop do
    rom = container["persistence.rom"]
    rom&.disconnect
  end
end

```

- Consider to introduce `Hanami.reboot` (or `Hanami.application.reboot`) which will loop thru the initialised components and invoke `stop` and then `start`. This will make Puma’s `before_fork` much simpler

```auto
before_fork do
  Hanami.reboot
end

```

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:10pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/6 "2021-05-06T12:10:49Z")

</div>

`config/settings.rb`

- Is it possible to have hashes that are mapped to env vars? Something similar to what `config` gem does:

```auto
LOGGING__LEVEL=debug
LOGGING__STREAM=stdout

```

```auto
Hanami.application.settings do
  setting :logging do
    setting :level, MyApp::Types::String
    setting :stream, MyApp::Types::String
  end
end

```

To be used like this

```auto
module MyApp
  class Application < Hanami::Application
    config.logging = settings.logging
  end
end

```

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:11pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/7 "2021-05-06T12:11:15Z")

</div>

`config/application.rb`

- We should consider to implement `environment` block for selectively setup configurations:

```auto
module MyApp
  class Application < Hanami::Application
    config.environment(:test) do
      # activate this block only if Hanami.env == :test
      config.logging = { ... }
    end
  end
end

```

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:11pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/8 "2021-05-06T12:11:34Z")

</div>

`lib/framework/web/assets.rb`

- must be moved to `hanami-assets`

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:12pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/9 "2021-05-06T12:12:04Z")

</div>

`lib/hanami/action/csrf_protection.rb`

- must be moved to `hanami-controller` and required internally by `hanami`.

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:12pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/10 "2021-05-06T12:12:20Z")

</div>

`lib/hanami/cli/**/*.rb`

- must be moved to `hanami-cli`

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:12pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/11 "2021-05-06T12:12:38Z")

</div>

`lib/tasks`

- we should decide how to declare custom Rake tasks to make them available for the app

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:13pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/12 "2021-05-06T12:13:29Z")

</div>

`lib/my_app/action.rb`

- move `require “json”` to `hanami/action/flash.rb` source code in `hanami-controller` gem
- consider to include `Hanami::Action::Cookies` only if app configuration (`config/application.rb`) has cookies setup
- consider to include `Hanami::Action::Session` only if app configuration (`config/application.rb`) has sessions setup
- consider to include `Hanami::Action::CsrfProtection` only if app configuration (`config/application.rb`) has sessions setup
- these inclusions should be handled by the framework, and not appear in the generated code.

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:13pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/13 "2021-05-06T12:13:56Z")

</div>

`lib/my_app/entities.rb`

- consider to remove manual recursive require of the entities in favour of `zeitwerk` autoloading

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:14pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/14 "2021-05-06T12:14:16Z")

</div>

`lib/my_app/functions.rb`

- migrate from `transproc` (deprecated) to `dry-transformer`

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:14pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/15 "2021-05-06T12:14:41Z")

</div>

`lib/my_app/operation.rb`

- Consider to develop `Hanami::Operation` in `hanami`:

```auto
require "hanami/operation"

module MyApp
  class Operation < Hanami::Operation
  end
end

```

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:15pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/16 "2021-05-06T12:15:03Z")

</div>

`lib/my_app/validation/contract.rb`

- Why is this nested?
- Generate `i18n` configuration for validations

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 6, 2021, 12:15pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/17 "2021-05-06T12:15:33Z")

</div>

`lib/store/view/context.rb`

- consider to develop `Hanami::View::ApplicationContext` in `hanami-view`, which will include this default setup:

```auto
modue MyApp
  module View
    class Context < Hanami::View::ApplicationContext
    end
  end
end

```

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [May 8, 2021, 2:11pm UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/18 "2021-05-08T14:11:43Z")

</div>

> <https://github.com/hanami/hanami-2-application-template/pull/23>
>
> This change aims to replace \`transproc\` which is deprecated.

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/solnic/32/757_2.png) [@solnic](https://discourse.hanakai.org/u/solnic)\
**Post date:** [May 10, 2021, 7:59am UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/19 "2021-05-10T07:59:59Z")

</div>

> [@jodosha](#):
>
> `config/boot/persistence.rb`
> 
> - must be ported to `hanami`

I was thinking about shipping rom (the gem) with built-in system components. So then, in hanami, you’d be able to just do something like this:

```ruby
# config/boot/persistence.rb
Hanami.application.register_bootable(:persistence, from: :rom) do |container|
  after(:init) do
    container["rom.config"].plugin(:sql, relations: :auto_restrictions)
  end
end

```

In the most simplistic use-case, this would just work too:

```ruby
require "hanami"

module Bookshelf
  class Application < Hanami::Application
     # this would result in having container["rom"] registered
     # based on DATABASE_URL setting
    register_bootable(:persistence, from: :rom)
  end
end

```

I also need to figure out how to pre-configure instrumentation, that’s a bit tricky because `notifications` object that’s used for instrumentation is provided by hanami.

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/solnic/32/757_2.png) [@solnic](https://discourse.hanakai.org/u/solnic)\
**Post date:** [May 10, 2021, 8:02am UTC](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606/20 "2021-05-10T08:02:06Z")

</div>

> [@jodosha](#):
>
> `lib/my_app/entities.rb`
> 
> - consider to remove manual recursive require of the entities in favour of `zeitwerk` autoloading

This will go away 🙂 I’ll be adding support for pre-configured structs directly to rom core. BTW I’m for renaming `Entity => Struct` and sticking to it. This can be of course configurable, but I would vote for using `Struct` as the default name because `Entity` can be confused with stuff from DDD where identity is based on a key value (IIRC).

[Next page](https://discourse.hanakai.org/t/hanami-v2-0-0-alpha2-app-template-feedback/606.md?page=2)
