Class: Cli::Commands::NewApp::Files::Routes
- Inherits:
-
Object
- Object
- Cli::Commands::NewApp::Files::Routes
- Defined in:
- lib/cli/commands/new_app/files/routes.rb
Class Method Summary collapse
- .base_controller ⇒ Object
- .call(app_name) ⇒ Object
- .health_controller(app_name) ⇒ Object
- .router ⇒ Object
Class Method Details
.base_controller ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cli/commands/new_app/files/routes.rb', line 34 def self.base_controller <<~RUBY # typed: strict # frozen_string_literal: true module Controllers class Base < Kirei::Controller extend T::Sig end end RUBY end |
.call(app_name) ⇒ Object
8 9 10 11 12 |
# File 'lib/cli/commands/new_app/files/routes.rb', line 8 def self.call(app_name) File.write("config/routes.rb", router) File.write("app/controllers/base.rb", base_controller) File.write("app/controllers/health.rb", health_controller(app_name)) end |
.health_controller(app_name) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cli/commands/new_app/files/routes.rb', line 47 def self.health_controller(app_name) <<~RUBY # typed: strict # frozen_string_literal: true module Controllers class Health < Base sig { returns(T.anything) } def livez #{app_name}.config.logger.info("Health check") #{app_name}.config.logger.info(params.inspect) render(#{app_name}.version, status: 200) end end end RUBY end |
.router ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cli/commands/new_app/files/routes.rb', line 14 def self.router <<~RUBY # typed: strict # frozen_string_literal: true module Kirei::Routing Router.add_routes( [ Route.new( verb: Verb::GET, path: "/livez", controller: Controllers::Health, action: "livez", ), ], ) end RUBY end |