trailblazer-endpoint 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -0
  3. data/Appraisals +5 -0
  4. data/CHANGES.md +6 -0
  5. data/Rakefile +7 -1
  6. data/gemfiles/rails_app.gemfile +12 -0
  7. data/lib/trailblazer/endpoint.rb +20 -5
  8. data/lib/trailblazer/endpoint/adapter.rb +30 -121
  9. data/lib/trailblazer/endpoint/builder.rb +1 -1
  10. data/lib/trailblazer/endpoint/controller.rb +203 -1
  11. data/lib/trailblazer/endpoint/dsl.rb +6 -3
  12. data/lib/trailblazer/endpoint/options.rb +13 -44
  13. data/lib/trailblazer/endpoint/protocol.rb +5 -8
  14. data/lib/trailblazer/endpoint/version.rb +1 -1
  15. data/test/adapter/api_test.rb +6 -11
  16. data/test/adapter/web_test.rb +2 -5
  17. data/test/config_test.rb +25 -0
  18. data/test/docs/controller_test.rb +160 -73
  19. data/test/endpoint_test.rb +1 -1
  20. data/test/rails-app/.gitignore +8 -2
  21. data/test/rails-app/.ruby-version +1 -0
  22. data/test/rails-app/Gemfile +11 -9
  23. data/test/rails-app/Gemfile.lock +137 -121
  24. data/test/rails-app/app/concepts/app/api/v1/representer/errors.rb +16 -0
  25. data/test/rails-app/app/concepts/auth/jwt.rb +35 -0
  26. data/test/rails-app/app/concepts/auth/operation/authenticate.rb +32 -0
  27. data/test/rails-app/app/concepts/auth/operation/policy.rb +9 -0
  28. data/test/rails-app/app/concepts/song/operation/create.rb +13 -0
  29. data/test/rails-app/app/concepts/song/operation/show.rb +10 -0
  30. data/test/rails-app/app/concepts/song/representer.rb +5 -0
  31. data/test/rails-app/app/controllers/api/v1/songs_controller.rb +35 -0
  32. data/test/rails-app/app/controllers/application_controller.rb +6 -1
  33. data/test/rails-app/app/controllers/application_controller/api.rb +105 -0
  34. data/test/rails-app/app/controllers/application_controller/web.rb +30 -0
  35. data/test/rails-app/app/controllers/songs_controller.rb +15 -17
  36. data/test/rails-app/app/models/song.rb +3 -0
  37. data/test/rails-app/app/models/user.rb +5 -0
  38. data/test/rails-app/bin/bundle +114 -0
  39. data/test/rails-app/bin/rails +4 -0
  40. data/test/rails-app/bin/rake +4 -0
  41. data/test/rails-app/bin/setup +33 -0
  42. data/test/rails-app/config/application.rb +26 -3
  43. data/test/rails-app/config/credentials.yml.enc +1 -0
  44. data/test/rails-app/config/database.yml +2 -2
  45. data/test/rails-app/config/environments/development.rb +7 -17
  46. data/test/rails-app/config/environments/production.rb +28 -23
  47. data/test/rails-app/config/environments/test.rb +8 -12
  48. data/test/rails-app/config/initializers/application_controller_renderer.rb +6 -4
  49. data/test/rails-app/config/initializers/cors.rb +16 -0
  50. data/test/rails-app/config/initializers/trailblazer.rb +2 -0
  51. data/test/rails-app/config/locales/en.yml +11 -1
  52. data/test/rails-app/config/master.key +1 -0
  53. data/test/rails-app/config/routes.rb +8 -3
  54. data/test/rails-app/db/schema.rb +15 -0
  55. data/test/rails-app/test/controllers/api_songs_controller_test.rb +83 -0
  56. data/test/rails-app/test/controllers/songs_controller_test.rb +36 -144
  57. data/test/rails-app/test/test_helper.rb +7 -1
  58. data/test/test_helper.rb +0 -2
  59. data/trailblazer-endpoint.gemspec +1 -0
  60. metadata +52 -21
  61. data/test/rails-app/config/initializers/cookies_serializer.rb +0 -5
  62. data/test/rails-app/config/initializers/new_framework_defaults.rb +0 -24
  63. data/test/rails-app/config/initializers/session_store.rb +0 -3
  64. data/test/rails-app/config/secrets.yml +0 -22
  65. data/test/rails-app/test/helpers/.keep +0 -0
  66. data/test/rails-app/test/integration/.keep +0 -0
  67. data/test/rails-app/test/mailers/.keep +0 -0
  68. data/test/rails-app/vendor/assets/javascripts/.keep +0 -0
  69. data/test/rails-app/vendor/assets/stylesheets/.keep +0 -0
@@ -0,0 +1,13 @@
1
+ module Song::Operation
2
+ class Create < Trailblazer::Operation
3
+ # include Trailblazer::Activity::Testing.def_steps(:model, :validate, :save)
4
+ step :model
5
+ # step :validate
6
+ # step :save
7
+
8
+ def model(ctx, params:, **)
9
+ return unless params[:id]
10
+ ctx[:model] = Song.new(params[:id])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module Song::Operation
2
+ class Show < Trailblazer::Operation
3
+ step :model, Output(:failure) => End(:not_found)
4
+
5
+ def model(ctx, params:, **)
6
+ return unless params[:id] == "1"
7
+ ctx[:model] = Song.new(params[:id])
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class Song::Representer < Representable::Decorator
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ end
@@ -0,0 +1,35 @@
1
+ #:controller
2
+ module Api
3
+ module V1
4
+ class SongsController < ApplicationController::Api
5
+ endpoint Song::Operation::Create.to_s, domain_activity: Song::Operation::Create
6
+ endpoint Song::Operation::Show.to_s, domain_activity: Song::Operation::Show do {Output(:not_found) => Track(:not_found)} end
7
+
8
+ #:create
9
+ def create
10
+ endpoint Song::Operation::Create.to_s, representer_class: Song::Representer
11
+ end
12
+ #:create end
13
+
14
+ def show
15
+ endpoint Song::Operation::Show.to_s, representer_class: Song::Representer
16
+ end
17
+
18
+ def show_with_options
19
+ endpoint Song::Operation::Show.to_s, representer_class: Song::Representer, protocol_failure_block: ->(ctx, endpoint_ctx:, **) { head endpoint_ctx[:status] + 1 }
20
+ end
21
+
22
+ class WithOptionsController < ApplicationController::Api
23
+ endpoint Song::Operation::Show.to_s, domain_activity: Song::Operation::Show do {Output(:not_found) => Track(:not_found)} end
24
+
25
+ #:show-options
26
+ def show
27
+ endpoint Song::Operation::Show.to_s, representer_class: Song::Representer,
28
+ protocol_failure_block: ->(ctx, endpoint_ctx:, **) { head endpoint_ctx[:status] + 1 }
29
+ end
30
+ #:show-options end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ #:controller end
@@ -1,3 +1,8 @@
1
+ require "trailblazer/endpoint/controller"
2
+
1
3
  class ApplicationController < ActionController::Base
2
- protect_from_forgery with: :exception
4
+
3
5
  end
6
+
7
+
8
+ # directive
@@ -0,0 +1,105 @@
1
+ #:app-controller
2
+ class ApplicationController::Api < ApplicationController
3
+ include Trailblazer::Endpoint::Controller.module(api: true)
4
+
5
+ def self.options_for_block_options(ctx, controller:, **)
6
+ response_block = ->(ctx, endpoint_ctx:, **) do
7
+ controller.render json: endpoint_ctx[:representer], status: endpoint_ctx[:status]
8
+ end
9
+
10
+ {
11
+ success_block: response_block,
12
+ failure_block: response_block,
13
+ protocol_failure_block: response_block
14
+ }
15
+ end
16
+
17
+ directive :options_for_block_options, method(:options_for_block_options)
18
+ #:app-controller end
19
+
20
+ #:options_for_endpoint
21
+ def self.options_for_endpoint(ctx, controller:, **)
22
+ {
23
+ request: controller.request,
24
+ errors_representer_class: App::Api::V1::Representer::Errors,
25
+ errors: Trailblazer::Endpoint::Adapter::API::Errors.new,
26
+ }
27
+ end
28
+
29
+ directive :options_for_endpoint, method(:options_for_endpoint)
30
+ #:options_for_endpoint end
31
+
32
+ #:options_for_domain_ctx
33
+ def self.options_for_domain_ctx(ctx, controller:, **) # TODO: move to ApplicationController
34
+ {
35
+ params: controller.params,
36
+ }
37
+ end
38
+
39
+ directive :options_for_domain_ctx, method(:options_for_domain_ctx)
40
+ #:options_for_domain_ctx end
41
+
42
+ #:protocol
43
+ class Protocol < Trailblazer::Endpoint::Protocol
44
+ step Auth::Operation::Policy, inherit: true, id: :policy, replace: :policy
45
+ step Subprocess(Auth::Operation::Authenticate), inherit: true, id: :authenticate, replace: :authenticate
46
+ end
47
+ #:protocol end
48
+
49
+ #:adapter
50
+ module Adapter
51
+ class Representable < Trailblazer::Endpoint::Adapter::API
52
+ step :render # added before End.success
53
+ step :render_errors, after: :_422_status, magnetic_to: :failure, Output(:success) => Track(:failure)
54
+ step :render_errors, after: :protocol_failure, magnetic_to: :fail_fast, Output(:success) => Track(:fail_fast), id: :render_protocol_failure_errors
55
+
56
+ def render(ctx, domain_ctx:, representer_class:, **) # this is what usually happens in your {Responder}.
57
+ ctx[:representer] = representer_class.new(domain_ctx[:model] || raise("no model found!"))
58
+ end
59
+
60
+ def render_errors(ctx, errors:, errors_representer_class:, **) # TODO: extract with {render}
61
+ ctx[:representer] = errors_representer_class.new(errors)
62
+ end
63
+
64
+ Trailblazer::Endpoint::Adapter::API.insert_error_handler_steps!(self)
65
+ include Trailblazer::Endpoint::Adapter::API::Errors::Handlers # handler methods to set an error message.
66
+ end # Representable
67
+ end
68
+ #:adapter end
69
+
70
+ puts Trailblazer::Developer.render(Adapter::Representable)
71
+
72
+ #:endpoint
73
+ # app/controllers/application_controller/api.rb
74
+ endpoint protocol: Protocol, adapter: Adapter::Representable do
75
+ # {Output(:not_found) => Track(:not_found)}
76
+ {}
77
+ end
78
+ #:endpoint end
79
+ end
80
+
81
+
82
+ # header 'Authorization', "Bearer #{result['jwt_token']}" if result['jwt_token']
83
+
84
+
85
+ # ΓΞΞ Protocol ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˥
86
+ # | (Start)--->[Authenticate]-->[Policy]-->[Show]----------->((success)) |
87
+ # | | | | L------------->((failure)) |
88
+ # | | | L------------->((not_found)) |
89
+ # | | L------------------->((not_authorized)) |
90
+ # | L----------------------------->((not_authenticated)) |
91
+ # | ((invalid_data)) |
92
+ # LΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˩
93
+ #--˥˩ ˪
94
+
95
+ # ΓΞΞ Adapter::Representable ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˥
96
+ # | |
97
+ # | (Start)---> ΓΞΞ Protocol ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˥ |
98
+ # | (Start)--->[Authenticate]-->[Policy]-->[Show]----------->((success)) |--->[_200_status]--->[render]---------------------------------------------------------------->((success)) |
99
+ # | | | | L------------->((failure)) |-˥ |
100
+ # | | | L------------->((not_found)) |-|------------------------------->[_404_status]-----------v |
101
+ # | | L------------------->((not_authorized)) |-|->[handle_not_authorized]------>[_403_status]--->[protocol_failure]--->[render_errors]--->((fail_fast)) |
102
+ # | L----------------------------->((not_authenticated)) |-|->[handle_not_authenticated]--->[_401_status]-----------^ |
103
+ # | ((invalid_data)) |-┴->[handle_invalid_data]-------->[_422_status]--->[render_errors]--------------------------->((failure)) |
104
+ # LΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˩ |
105
+ # LΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ˩
@@ -0,0 +1,30 @@
1
+ class ApplicationController::Web < ApplicationController
2
+ extend Trailblazer::Endpoint::Controller
3
+ include Trailblazer::Endpoint::Controller::InstanceMethods::DSL
4
+ include Trailblazer::Endpoint::Controller::Rails
5
+ extend Trailblazer::Endpoint::Controller::Rails::DefaultBlocks
6
+ extend Trailblazer::Endpoint::Controller::Rails::DefaultParams
7
+ include Trailblazer::Endpoint::Controller::Rails::Process
8
+
9
+ # directive :options_for_endpoint, method(:options_for_endpoint), method(:request_options)
10
+ # directive :options_for_flow_options, method(:options_for_flow_options)
11
+ # directive :options_for_block_options, method(:options_for_block_options)
12
+
13
+ Protocol = Class.new(Trailblazer::Endpoint::Protocol) do
14
+ # no {:seq} dependency
15
+ def authenticate(ctx, domain_ctx:, **)
16
+ # puts domain_ctx[:params].inspect
17
+
18
+ puts "TODO: should we always inject params into the endpoint_ctx?"
19
+ domain_ctx[:params][:authenticate] == "false" ? false : true
20
+ end
21
+
22
+ def policy(ctx, domain_ctx:, **)
23
+ domain_ctx[:params][:policy] == "false" ? false : true
24
+ end
25
+ end
26
+
27
+ endpoint protocol: Protocol, adapter: Trailblazer::Endpoint::Adapter::Web do
28
+ {Output(:not_found) => Track(:not_found)}
29
+ end
30
+ end
@@ -1,26 +1,24 @@
1
- class SongsController < ApplicationController
2
- require "trailblazer/endpoint/rails"
3
- include Trailblazer::Endpoint::Controller
1
+ class SongsController < ApplicationController::Web
2
+ endpoint("Create", domain_activity: Song::Operation::Create) do {} end # FIXME: we still need to provide an empty hash here if we want to override the not_found behavior.
4
3
 
5
- def create
6
- endpoint Create, path: songs_path, args: [ params, { "user.current" => ::Module } ]
7
- end
8
-
9
- def update
10
- endpoint Update, path: songs_path, args: [params]
11
- end
4
+ # directive :options_for_domain_ctx, ->(ctx, **) { {seq: []} }
12
5
 
13
- def update_with_user
14
- endpoint Update, path: songs_path, args: [ params, { "user.current" => ::Module } ]
6
+ def create
7
+ endpoint "Create"
15
8
  end
16
9
 
17
- def show
18
- endpoint Show, path: songs_path, args: [ params, { "user.current" => ::Module } ]
10
+ def create_with_options
11
+ endpoint "Create", process_model: "yay!" do |ctx, model:, endpoint_ctx:, **|
12
+ # TODO test process_model
13
+ render json: [model, endpoint_ctx[:process_model]]
14
+ end
19
15
  end
20
16
 
21
- def create_with_custom_handlers
22
- endpoint Create, path: songs_path, args: [ params, { "user.current" => ::Module } ] do |m|
23
- m.created { |result| render json: result["representer.serializer.class"].new(result["model"]), status: 999 }
17
+ def create_with_or
18
+ endpoint "Create" do |ctx, model:, **|
19
+ render json: {or: model}
20
+ end.Or do |ctx, model:, endpoint_ctx:, **|
21
+ render json: model, status: 422
24
22
  end
25
23
  end
26
24
  end
@@ -0,0 +1,3 @@
1
+ class Song < Struct.new(:id)
2
+
3
+ end
@@ -0,0 +1,5 @@
1
+ class User < Struct.new(:id, :email)
2
+ def self.find_by(id:)
3
+ return User.new(id, "yogi@trb.to") if id.to_s == "1"
4
+ end
5
+ end
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to setup or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?('config/database.yml')
22
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! 'bin/rails db:prepare'
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! 'bin/rails log:clear tmp:clear'
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! 'bin/rails restart'
33
+ end
@@ -1,6 +1,20 @@
1
+ require 'uri'
1
2
  require_relative 'boot'
2
3
 
3
- require 'rails/all'
4
+ require "rails"
5
+ # Pick the frameworks you want:
6
+ require "active_model/railtie"
7
+ # require "active_job/railtie"
8
+ require "active_record/railtie"
9
+ # require "active_storage/engine"
10
+ require "action_controller/railtie"
11
+ # require "action_mailer/railtie"
12
+ # require "action_mailbox/engine"
13
+ # require "action_text/engine"
14
+ # require "action_view/railtie"
15
+ # require "action_cable/engine"
16
+ # require "sprockets/railtie"
17
+ require "rails/test_unit/railtie"
4
18
 
5
19
  # Require the gems listed in Gemfile, including any gems
6
20
  # you've limited to :test, :development, or :production.
@@ -8,8 +22,17 @@ Bundler.require(*Rails.groups)
8
22
 
9
23
  module RailsApp
10
24
  class Application < Rails::Application
25
+ # Initialize configuration defaults for originally generated Rails version.
26
+ config.load_defaults 6.0
27
+
11
28
  # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
29
+ # Application configuration can go into files in config/initializers
30
+ # -- all .rb files in that directory are automatically loaded after loading
31
+ # the framework and any gems in your application.
32
+
33
+ # Only loads a smaller set of middleware suitable for API only apps.
34
+ # Middleware like session, flash, cookies can be added back manually.
35
+ # Skip views, helpers and assets when generating a new resource.
36
+ config.api_only = true
14
37
  end
15
38
  end