Class: Cli::Commands::NewApp::Files::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/commands/new_app/files/routes.rb

Class Method Summary collapse

Class Method Details

.base_controllerObject



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
  "    # typed: strict\n    # frozen_string_literal: true\n\n    module Controllers\n      class Base < Kirei::Controller\n        extend T::Sig\n      end\n    end\n  RUBY\nend\n"

.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)
  "    # typed: strict\n    # frozen_string_literal: true\n\n    module Controllers\n      class Health < Base\n        sig { returns(T.anything) }\n        def livez\n          \#{app_name}.config.logger.info(\"Health check\")\n          \#{app_name}.config.logger.info(params.inspect)\n          render(\#{app_name}.version, status: 200)\n        end\n      end\n    end\n  RUBY\nend\n"

.routerObject



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
  "    # typed: strict\n    # frozen_string_literal: true\n\n    module Kirei::Routing\n      Router.add_routes(\n        [\n          Route.new(\n            verb: Verb::GET,\n            path: \"/livez\",\n            controller: Controllers::Health,\n            action: \"livez\",\n          ),\n        ],\n      )\n    end\n  RUBY\nend\n"