rrx_api
Advanced tools
| # frozen_string_literal: true | ||
| module RrxApi | ||
| # Replaces the default Rails health check controller | ||
| class HealthController < RrxApi::Controller | ||
| rescue_from(Exception) { |error| render_down(error) } | ||
| def show | ||
| check | ||
| render_up | ||
| end | ||
| protected | ||
| def check | ||
| healthcheck = Rails.application.config.healthcheck | ||
| instance_exec(&healthcheck) if healthcheck.respond_to?(:call) | ||
| end | ||
| def render_up | ||
| render json: { status: 'up' }, status: :ok | ||
| end | ||
| # @param [Exception] error | ||
| def render_down(error) | ||
| render json: { | ||
| status: 'down', | ||
| message: error.message, | ||
| full_message: error.full_message(order: :top) | ||
| }, status: :internal_server_error | ||
| end | ||
| end | ||
| end |
| RrxApi::Engine.routes.draw do | ||
| if Rails.root.join('swagger').exist? | ||
| require 'rswag/api/engine' | ||
| require 'rswag/ui/engine' | ||
| mount Rswag::Ui::Engine => '/api-docs' | ||
| mount Rswag::Api::Engine => '/api-docs' | ||
| end | ||
| healthcheck_path = Rails.application.config.healthcheck_route | ||
| healthcheck_path = "/#{healthcheck_path}" unless healthcheck_path.start_with?('/') | ||
| get healthcheck_path => 'rrx_api/health#show', as: :rrx_health_check | ||
| end |
| # frozen_string_literal: true | ||
| module RrxApi | ||
| module Generators | ||
| class Base < ::Rails::Generators::Base | ||
| hide! | ||
| def self.init!(description = nil) | ||
| # noinspection RubyMismatchedArgumentType | ||
| source_root Pathname(__dir__).join('templates') | ||
| desc description if description | ||
| end | ||
| protected | ||
| # class Version | ||
| # def initialize(str) | ||
| # @version = str.to_s | ||
| # @segments = @version.split('.').map(&:to_i) | ||
| # end | ||
| # | ||
| # def to_s | ||
| # @version | ||
| # end | ||
| # | ||
| # def major | ||
| # @segments[0] | ||
| # end | ||
| # | ||
| # def minor | ||
| # @segments[1] | ||
| # end | ||
| # | ||
| # def build | ||
| # @segments[2] || 0 | ||
| # end | ||
| # | ||
| # def major_minor | ||
| # "#{major}.#{minor}" | ||
| # end | ||
| # | ||
| # def <=>(other) | ||
| # return nil unless other.is_a?(Version) | ||
| # | ||
| # result = major <=> other.major | ||
| # result = minor <=> other.minor if result.zero? | ||
| # result = build <=> other.build if result.zero? | ||
| # result | ||
| # end | ||
| # end | ||
| def destination_path | ||
| @destination_path = Pathname(destination_root) | ||
| end | ||
| def app_name | ||
| @app_name ||= destination_path.basename.to_s | ||
| end | ||
| # @return [String] Current Ruby version in format "MAJOR.MINOR" | ||
| def ruby_version | ||
| @ruby_version ||= bundle_max_ruby_version || current_ruby_version | ||
| end | ||
| # @return [Bundler::Definition] | ||
| def bundle | ||
| @bundle ||= Bundler::Definition.build( | ||
| destination_path.join('Gemfile'), | ||
| destination_path.join('Gemfile.lock'), | ||
| nil | ||
| ) | ||
| end | ||
| def current_ruby_version | ||
| RUBY_VERSION.split('.')[0..1].join('.') | ||
| end | ||
| def bundle_max_ruby_version | ||
| return nil unless bundle.ruby_version | ||
| version = Gem::Requirement.new(*bundle.ruby_version.versions) | ||
| max_minor = version | ||
| .requirements | ||
| .map { |_, v| v.segments[0..1] } # [major, minor] | ||
| if max_minor.any? | ||
| max_minor.min_by { |major, minor| [major, minor] }.join('.') | ||
| else | ||
| nil | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
| # frozen_string_literal: true | ||
| require_relative 'base' | ||
| module RrxApi | ||
| module Generators | ||
| class DockerGenerator < Base | ||
| init! 'Generates configuration files for building a docker image.' | ||
| class_option :image_name, type: :string, desc: 'Name of the Docker image. Defaults to application name.' | ||
| def docker | ||
| template 'docker/Dockerfile.tt', 'Dockerfile' | ||
| end | ||
| alias image_name app_name | ||
| end | ||
| end | ||
| end |
| # frozen_string_literal: true | ||
| require_relative 'base' | ||
| module RrxApi | ||
| module Generators | ||
| class GithubGenerator < Base | ||
| init! 'Generates GitHub Actions workflows for building and deploying the application using Docker.' | ||
| class_option :deploy, | ||
| type: :boolean, | ||
| default: false, | ||
| desc: 'Include deployment workflow' | ||
| class_option :terraform_repo, | ||
| type: :string, | ||
| default: 'terraform', | ||
| desc: 'Terraform repository name (if using deployment workflow)' | ||
| class_option :terraform_module, | ||
| type: :string, | ||
| desc: 'Terraform module name (if using deployment workflow). Default is the application name.' | ||
| class_option :database, | ||
| type: :string, | ||
| default: 'auto', | ||
| enum: %w[auto postgresql mysql mariadb sqlite none], | ||
| desc: 'Database type' | ||
| def github | ||
| directory 'github/build', '.github' | ||
| directory 'github/deploy', '.github' if deploy? | ||
| end | ||
| private | ||
| def deploy? | ||
| options[:deploy] | ||
| end | ||
| def database | ||
| @database ||= options[:database] == 'auto' ? detect_database : options[:database] | ||
| end | ||
| def terraform_repo | ||
| options[:terraform_repo] | ||
| end | ||
| def terraform_module | ||
| options[:terraform_module] || app_name | ||
| end | ||
| def docker_packages | ||
| '' | ||
| end | ||
| def detect_database | ||
| config_path = destination_path.join('config/database.yml') | ||
| if config_path.exist? | ||
| # @type {Hash} | ||
| config = YAML.safe_load(config_path.read, symbolize_names: true, aliases: true) | ||
| adapter = config.dig(:test, :adapter).to_s.downcase | ||
| case adapter | ||
| when /postgresql/, /psql/ | ||
| 'postgresql' | ||
| when /mysql/ | ||
| if yes?('Detected MySQL adapter in database.yml. Are you using MariaDB? (Yn)') | ||
| 'mariadb' | ||
| else | ||
| 'mysql' | ||
| end | ||
| when /sqlite/ | ||
| 'sqlite' | ||
| else | ||
| say_error 'Unsupported database adapter detected in config/database.yml. Please specify the database type explicitly using --database option.' | ||
| exit 1 | ||
| end | ||
| else | ||
| 'none' | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
| # frozen_string_literal: true | ||
| # frozen_string_literal: true | ||
| require_relative 'base' | ||
| module RrxApi | ||
| module Generators | ||
| class InstallGenerator < Base | ||
| init! 'Installs the RRX API gem and its dependencies.' | ||
| class_option :skip_rrx_dev, type: :boolean, default: false, hide: true | ||
| # Updates the application configuration file with specific dependencies and settings. | ||
| # The method performs the following operations: | ||
| # - Reads the application configuration file located at 'config/application.rb'. | ||
| # - Removes existing comments and unnecessary `require` statements from the file. | ||
| # - Includes necessary `require` directives for the application's gem dependencies. | ||
| # - Injects or updates the Bundler require statement to include the necessary gems. | ||
| # - Cleans up unwanted whitespace in the file content. | ||
| # - Rewrites the configuration file with the updated content. | ||
| # - Appends additional configuration settings for time zone, schema format, and session management. | ||
| # | ||
| # @return [void] Since the primary purpose is file modification, it does not return a value directly. | ||
| def update_application | ||
| # @type [Pathname] | ||
| app_file = Pathname(destination_root).join('config', 'application.rb') | ||
| app_code = app_file.read | ||
| # Assume full replace if we've never modified before. | ||
| # Otherwise, create_file will prompt to replace it. | ||
| remove_file app_file unless app_code =~ /rrx_api/ | ||
| app_code.gsub!(/^\s*#.*\r?\n/, '') | ||
| app_code.gsub!(/^(?:#\s+)?require ["'].*\r?\n/, '') | ||
| requires = application_gems.map do |gem| | ||
| "require '#{gem}'" | ||
| end.join("\n") | ||
| app_code.sub!(/^(Bundler.require.*)$/) do |str| | ||
| <<~REQ | ||
| #{requires} | ||
| #{str} | ||
| REQ | ||
| end | ||
| # Remove existing application config lines | ||
| APPLICATION_CONFIG.each do |line| | ||
| app_code.gsub!(/^\s*#{line}\W*.*\n/, '') | ||
| end | ||
| # Remove unnecessary whitespace | ||
| app_code.lstrip! | ||
| app_code.gsub!(/^\s*\r?\n(\s*\r?\n)+/, "\n") | ||
| # puts app_code | ||
| create_file app_file, app_code | ||
| end | ||
| def update_base_classes | ||
| gsub_file 'app/models/application_record.rb', | ||
| /ApplicationRecord.*/, | ||
| 'ApplicationRecord < RrxApi::Record' | ||
| gsub_file 'app/controllers/application_controller.rb', | ||
| /ApplicationController.*/, | ||
| 'ApplicationController < RrxApi::Controller' | ||
| end | ||
| def routes | ||
| inject_into_file 'config/routes.rb', | ||
| after: "Rails.application.routes.draw do\n" do | ||
| <<~RUBY | ||
| mount RrxApi::Engine => '/' | ||
| RUBY | ||
| end | ||
| end | ||
| def rrx_dev | ||
| generate 'rrx_dev:install' unless options[:skip_rrx_dev] | ||
| end | ||
| def asdf_versions | ||
| create_file '.tool-versions', <<~VERSIONS | ||
| ruby #{ruby_version} | ||
| VERSIONS | ||
| end | ||
| private | ||
| # Configs to remove from the application.rb file | ||
| APPLICATION_CONFIG = <<~CONFIG.split("\n").map(&:strip).freeze | ||
| config.time_zone | ||
| config.active_support.to_time_preserves_timezone | ||
| config.active_record.schema_format | ||
| config.session_store | ||
| config.middleware.use ActionDispatch::Cookies | ||
| config.middleware.use ActionDispatch::Session::CookieStore | ||
| CONFIG | ||
| # @return [Array<String>] The list of application gem names that are dependencies | ||
| def application_gems | ||
| gems = %w[rrx_api] | ||
| gems.concat(%w[rrx_jobs active_job].select { |name| gem?(name) }) | ||
| end | ||
| # @param [String] name | ||
| # @return [Boolean] True if gem is a dependency | ||
| def gem?(name) | ||
| bundle_gems.include?(name) | ||
| end | ||
| # @return [Set<String>] | ||
| def bundle_gems | ||
| @bundle_gems ||= bundle.dependencies.map(&:name).to_set | ||
| end | ||
| end | ||
| end | ||
| end |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
| # frozen_string_literal: true | ||
| require_relative 'base' | ||
| module RrxApi | ||
| module Generators | ||
| class TerraformGenerator < Base | ||
| init! 'Generates Terraform scripts for deploying the service as a docker container.' | ||
| class_option :cloud, | ||
| default: 'aws', | ||
| enum: %w[aws], | ||
| desc: 'Cloud provider for deployment (currently only AWS is supported)' | ||
| class_option :bucket, | ||
| type: :string, | ||
| desc: 'S3 bucket name for storing Terraform state files (default: store state locally)' | ||
| class_option :key, | ||
| type: :string, | ||
| desc: 'S3 key for the Terraform state file (default: app name)' | ||
| class_option :aws_profile, | ||
| type: :string, | ||
| desc: 'AWS profile to use for deployment (default: current profile)' | ||
| class_option :aws_region, | ||
| type: :string, | ||
| default: 'us-west-2', | ||
| desc: 'AWS region for deployment (default: us-west-2)' | ||
| class_option :ecs_cluster, | ||
| type: :string, | ||
| desc: 'ECS cluster name for deployment (default: deployment environment name)' | ||
| class_option :environments, | ||
| type: :boolean, | ||
| default: false, | ||
| aliases: '-e', | ||
| desc: 'Generate terraform files that targets multiple environments (default: false)' | ||
| def terraform | ||
| directory "terraform/#{options[:cloud]}", 'terraform' | ||
| end | ||
| private | ||
| def environments? | ||
| options[:environments] | ||
| end | ||
| def terraform_version | ||
| '1.9' | ||
| end | ||
| def s3_bucket | ||
| options[:bucket] | ||
| end | ||
| def s3_key | ||
| options[:key] || app_name | ||
| end | ||
| def aws_profile | ||
| options[:aws_profile] | ||
| end | ||
| def aws_region | ||
| options[:aws_region] | ||
| end | ||
| def ecs_cluster | ||
| options.include?(:ecs_cluster) ? "'#{options[:ecs_cluster]}'" : 'terraform.workspace' | ||
| end | ||
| end | ||
| end | ||
| end |
| require 'rails' | ||
| require 'active_model/railtie' | ||
| require 'active_record/railtie' | ||
| require 'action_controller/railtie' | ||
| require 'action_text/engine' | ||
| require 'action_view/railtie' | ||
| require 'jbuilder' | ||
| require 'rack/cors' | ||
| require 'actionpack/action_caching' | ||
| module RrxApi | ||
| class Engine < ::Rails::Engine | ||
| CORS_LOCALHOST_PATTERN = /\Ahttp:\/\/localhost(?::\d{4})?\z/.freeze | ||
| config.cors_origins = [] | ||
| config.healthcheck = nil | ||
| config.healthcheck_route = 'healthcheck' | ||
| initializer 'rrx.active_support', before: 'active_support.set_configs' do |app| | ||
| app.config.active_support.to_time_preserves_timezone = :zone | ||
| end | ||
| initializer 'rrx.application', before: :initialize do |app| | ||
| app.config.time_zone = :utc | ||
| app.config.active_support.to_time_preserves_timezone = :zone | ||
| app.config.active_record.schema_format = :sql # Use SQL schema format for UUID support | ||
| app.config.generators.orm :active_record, primary_key_type: :uuid | ||
| app.config.session_store :cookie_store, key: '_rrx_session' # Make configurable in the future? | ||
| app.config.middleware.use ActionDispatch::Cookies # Required for all session management | ||
| app.config.middleware.use ActionDispatch::Session::CookieStore, app.config.session_options | ||
| end | ||
| initializer 'rrx.cors', before: :load_config_initializers do |app| | ||
| require 'rack/cors' | ||
| Rails.application.config.middleware.insert_before 0, Rack::Cors do | ||
| allow do | ||
| origins do |source, _env| | ||
| if Rails.env.development? | ||
| CORS_LOCALHOST_PATTERN.match? source | ||
| else | ||
| app.config.cors_origins.include?(source) | ||
| end | ||
| end | ||
| resource '*', | ||
| headers: :any, | ||
| credentials: true, | ||
| methods: [:get, :post, :put, :patch, :delete, :options, :head] | ||
| end | ||
| end | ||
| end | ||
| initializer 'rrx.api_docs_config', before: :load_config_initializers do |_app| | ||
| Rails.configuration.api_docs = { 'API' => 'swagger.yaml' } | ||
| end | ||
| initializer 'rrx.api_docs', after: :load_config_initializers do |app| | ||
| # Setup Swagger endpoints if docs exist | ||
| if swagger_root? | ||
| require 'rswag/api' | ||
| require 'rswag/ui' | ||
| Rswag::Api.configure do |c| | ||
| c.swagger_root = Rails.root.join('swagger') | ||
| end | ||
| Rswag::Ui.configure do |c| | ||
| app.config.api_docs.each_pair do |name, file| | ||
| c.swagger_endpoint "/api-docs/#{file}", name | ||
| end | ||
| end | ||
| end | ||
| end | ||
| private | ||
| def swagger_root | ||
| @swagger_root ||= Rails.root.join('swagger') | ||
| end | ||
| def swagger_root? | ||
| swagger_root.exist? | ||
| end | ||
| end | ||
| end |
@@ -7,2 +7,4 @@ # frozen_string_literal: true | ||
| before_create :set_new_id | ||
| # @return [RrxLogging::Logger] | ||
@@ -12,3 +14,11 @@ def logger | ||
| end | ||
| protected | ||
| def set_new_id | ||
| self.id ||= Random.uuid if has_attribute?(:id) | ||
| end | ||
| end | ||
| end |
+3
-4
@@ -6,5 +6,4 @@ # frozen_string_literal: true | ||
| gem 'sqlite3' | ||
| gem 'rrx_dev', path: '~/dev/rrx/rrx_dev' | ||
| gem 'rrx_logging', path: '~/dev/rrx/rrx_logging' | ||
| PARENT_FOLDER = Pathname(__FILE__).parent.parent | ||
| gem 'rrx_dev', path: PARENT_FOLDER.join('rrx_dev') if PARENT_FOLDER.join('rrx_dev').exist? | ||
| gem 'rrx_logging', path: PARENT_FOLDER.join('rrx_logging') if PARENT_FOLDER.join('rrx_logging').exist? |
+126
-117
| PATH | ||
| remote: ../rrx_dev | ||
| specs: | ||
| rrx_dev (0.1.0) | ||
| rrx_dev (8.0.2) | ||
| active_record_query_trace | ||
| activesupport (~> 7.1.0) | ||
| activesupport (~> 8.0.2) | ||
| bootsnap | ||
| debug | ||
| factory_bot | ||
| factory_bot_rails | ||
| listen | ||
| railties (~> 7.1.0) | ||
| railties (~> 8.0.2) | ||
| rake (>= 13.0) | ||
@@ -25,6 +26,6 @@ rspec (>= 3.0) | ||
| specs: | ||
| rrx_logging (0.1.0) | ||
| activesupport | ||
| railties | ||
| rrx_config | ||
| rrx_logging (8.0.2) | ||
| activesupport (~> 8.0.2) | ||
| railties (~> 8.0.2) | ||
| rrx_config (~> 8.0.2) | ||
@@ -34,3 +35,3 @@ PATH | ||
| specs: | ||
| rrx_api (0.1.0) | ||
| rrx_api (8.0.2) | ||
| actionpack-action_caching | ||
@@ -40,12 +41,12 @@ bootsnap | ||
| faraday_middleware | ||
| jbuilder | ||
| jbuilder (~> 2.13) | ||
| kaminari | ||
| puma | ||
| rack-cors | ||
| rails (~> 7.0) | ||
| rails-healthcheck | ||
| rrx_config | ||
| rrx_logging | ||
| rails (~> 8.0.2) | ||
| rrx_config (~> 8.0.2) | ||
| rrx_logging (~> 8.0.2) | ||
| rswag-api | ||
| rswag-ui | ||
| thor | ||
| tzinfo-data | ||
@@ -56,33 +57,26 @@ | ||
| specs: | ||
| actioncable (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| actioncable (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| nio4r (~> 2.0) | ||
| websocket-driver (>= 0.6.1) | ||
| zeitwerk (~> 2.6) | ||
| actionmailbox (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| activejob (= 7.1.2) | ||
| activerecord (= 7.1.2) | ||
| activestorage (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| mail (>= 2.7.1) | ||
| net-imap | ||
| net-pop | ||
| net-smtp | ||
| actionmailer (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| actionview (= 7.1.2) | ||
| activejob (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| mail (~> 2.5, >= 2.5.4) | ||
| net-imap | ||
| net-pop | ||
| net-smtp | ||
| actionmailbox (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| activejob (= 8.0.2) | ||
| activerecord (= 8.0.2) | ||
| activestorage (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| mail (>= 2.8.0) | ||
| actionmailer (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| actionview (= 8.0.2) | ||
| activejob (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| mail (>= 2.8.0) | ||
| rails-dom-testing (~> 2.2) | ||
| actionpack (7.1.2) | ||
| actionview (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| actionpack (8.0.2) | ||
| actionview (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| nokogiri (>= 1.8.5) | ||
| racc | ||
| rack (>= 2.2.4) | ||
@@ -93,13 +87,14 @@ rack-session (>= 1.0.1) | ||
| rails-html-sanitizer (~> 1.6) | ||
| useragent (~> 0.16) | ||
| actionpack-action_caching (1.2.2) | ||
| actionpack (>= 4.0.0) | ||
| actiontext (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| activerecord (= 7.1.2) | ||
| activestorage (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| actiontext (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| activerecord (= 8.0.2) | ||
| activestorage (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| globalid (>= 0.6.0) | ||
| nokogiri (>= 1.8.5) | ||
| actionview (7.1.2) | ||
| activesupport (= 7.1.2) | ||
| actionview (8.0.2) | ||
| activesupport (= 8.0.2) | ||
| builder (~> 3.1) | ||
@@ -111,32 +106,36 @@ erubi (~> 1.11) | ||
| activerecord (>= 6.0.0) | ||
| activejob (7.1.2) | ||
| activesupport (= 7.1.2) | ||
| activejob (8.0.2) | ||
| activesupport (= 8.0.2) | ||
| globalid (>= 0.3.6) | ||
| activemodel (7.1.2) | ||
| activesupport (= 7.1.2) | ||
| activerecord (7.1.2) | ||
| activemodel (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| activemodel (8.0.2) | ||
| activesupport (= 8.0.2) | ||
| activerecord (8.0.2) | ||
| activemodel (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| timeout (>= 0.4.0) | ||
| activestorage (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| activejob (= 7.1.2) | ||
| activerecord (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| activestorage (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| activejob (= 8.0.2) | ||
| activerecord (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| marcel (~> 1.0) | ||
| activesupport (7.1.2) | ||
| activesupport (8.0.2) | ||
| base64 | ||
| benchmark (>= 0.3) | ||
| bigdecimal | ||
| concurrent-ruby (~> 1.0, >= 1.0.2) | ||
| concurrent-ruby (~> 1.0, >= 1.3.1) | ||
| connection_pool (>= 2.2.5) | ||
| drb | ||
| i18n (>= 1.6, < 2) | ||
| logger (>= 1.4.2) | ||
| minitest (>= 5.1) | ||
| mutex_m | ||
| tzinfo (~> 2.0) | ||
| securerandom (>= 0.3) | ||
| tzinfo (~> 2.0, >= 2.0.5) | ||
| uri (>= 0.13.1) | ||
| addressable (2.8.6) | ||
| public_suffix (>= 2.0.2, < 6.0) | ||
| ast (2.4.2) | ||
| base64 (0.2.0) | ||
| bigdecimal (3.1.5) | ||
| base64 (0.3.0) | ||
| benchmark (0.4.1) | ||
| bigdecimal (3.2.2) | ||
| binding_of_caller (1.0.0) | ||
@@ -146,6 +145,6 @@ debug_inspector (>= 0.0.1) | ||
| msgpack (~> 1.2) | ||
| builder (3.2.4) | ||
| builder (3.3.0) | ||
| coderay (1.1.3) | ||
| concurrent-ruby (1.2.2) | ||
| connection_pool (2.4.1) | ||
| concurrent-ruby (1.3.5) | ||
| connection_pool (2.5.3) | ||
| crass (1.0.6) | ||
@@ -158,5 +157,5 @@ date (3.3.4) | ||
| diff-lcs (1.5.0) | ||
| drb (2.2.0) | ||
| ruby2_keywords | ||
| erubi (1.12.0) | ||
| drb (2.2.3) | ||
| erb (5.0.2) | ||
| erubi (1.13.1) | ||
| factory_bot (6.4.5) | ||
@@ -193,11 +192,15 @@ activesupport (>= 5.0.0) | ||
| ffi (1.16.3) | ||
| generator_spec (0.10.0) | ||
| activesupport (>= 3.0.0) | ||
| railties (>= 3.0.0) | ||
| globalid (1.2.1) | ||
| activesupport (>= 6.1) | ||
| i18n (1.14.1) | ||
| i18n (1.14.7) | ||
| concurrent-ruby (~> 1.0) | ||
| io-console (0.7.1) | ||
| irb (1.11.0) | ||
| rdoc | ||
| reline (>= 0.3.8) | ||
| jbuilder (2.11.5) | ||
| irb (1.15.2) | ||
| pp (>= 0.6.0) | ||
| rdoc (>= 4.0.0) | ||
| reline (>= 0.4.2) | ||
| jbuilder (2.13.0) | ||
| actionview (>= 5.0.0) | ||
@@ -224,3 +227,4 @@ activesupport (>= 5.0.0) | ||
| rb-inotify (~> 0.9, >= 0.9.10) | ||
| loofah (2.22.0) | ||
| logger (1.7.0) | ||
| loofah (2.24.1) | ||
| crass (~> 1.0.2) | ||
@@ -235,6 +239,5 @@ nokogiri (>= 1.12.0) | ||
| mini_mime (1.1.5) | ||
| minitest (5.20.0) | ||
| minitest (5.25.5) | ||
| msgpack (1.7.2) | ||
| multipart-post (2.3.0) | ||
| mutex_m (0.2.0) | ||
| net-imap (0.4.9) | ||
@@ -250,3 +253,3 @@ date | ||
| nio4r (2.7.0) | ||
| nokogiri (1.16.0-x86_64-linux) | ||
| nokogiri (1.18.8-x86_64-linux-gnu) | ||
| racc (~> 1.4) | ||
@@ -257,2 +260,5 @@ parallel (1.24.0) | ||
| racc | ||
| pp (0.6.2) | ||
| prettyprint | ||
| prettyprint (0.2.0) | ||
| proc_to_ast (0.1.0) | ||
@@ -267,3 +273,3 @@ coderay | ||
| nio4r (~> 2.0) | ||
| racc (1.7.3) | ||
| racc (1.8.1) | ||
| rack (3.0.8) | ||
@@ -279,30 +285,27 @@ rack-cors (2.0.1) | ||
| webrick (~> 1.8) | ||
| rails (7.1.2) | ||
| actioncable (= 7.1.2) | ||
| actionmailbox (= 7.1.2) | ||
| actionmailer (= 7.1.2) | ||
| actionpack (= 7.1.2) | ||
| actiontext (= 7.1.2) | ||
| actionview (= 7.1.2) | ||
| activejob (= 7.1.2) | ||
| activemodel (= 7.1.2) | ||
| activerecord (= 7.1.2) | ||
| activestorage (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| rails (8.0.2) | ||
| actioncable (= 8.0.2) | ||
| actionmailbox (= 8.0.2) | ||
| actionmailer (= 8.0.2) | ||
| actionpack (= 8.0.2) | ||
| actiontext (= 8.0.2) | ||
| actionview (= 8.0.2) | ||
| activejob (= 8.0.2) | ||
| activemodel (= 8.0.2) | ||
| activerecord (= 8.0.2) | ||
| activestorage (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| bundler (>= 1.15.0) | ||
| railties (= 7.1.2) | ||
| rails-dom-testing (2.2.0) | ||
| railties (= 8.0.2) | ||
| rails-dom-testing (2.3.0) | ||
| activesupport (>= 5.0.0) | ||
| minitest | ||
| nokogiri (>= 1.6) | ||
| rails-healthcheck (1.4.0) | ||
| actionpack | ||
| railties | ||
| rails-html-sanitizer (1.6.0) | ||
| rails-html-sanitizer (1.6.2) | ||
| loofah (~> 2.21) | ||
| nokogiri (~> 1.14) | ||
| railties (7.1.2) | ||
| actionpack (= 7.1.2) | ||
| activesupport (= 7.1.2) | ||
| irb | ||
| nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) | ||
| railties (8.0.2) | ||
| actionpack (= 8.0.2) | ||
| activesupport (= 8.0.2) | ||
| irb (~> 1.13) | ||
| rackup (>= 1.0.0) | ||
@@ -317,9 +320,11 @@ rake (>= 12.2) | ||
| ffi (~> 1.0) | ||
| rdoc (6.6.2) | ||
| rdoc (6.14.2) | ||
| erb | ||
| psych (>= 4.0.0) | ||
| regexp_parser (2.8.3) | ||
| reline (0.4.1) | ||
| reline (0.6.1) | ||
| io-console (~> 0.5) | ||
| rexml (3.2.6) | ||
| rrx_config (0.1.0) | ||
| rrx_config (8.0.2) | ||
| activesupport | ||
| railties | ||
@@ -358,13 +363,13 @@ rspec (3.12.0) | ||
| rspec-support (3.12.1) | ||
| rswag-api (2.13.0) | ||
| activesupport (>= 3.1, < 7.2) | ||
| railties (>= 3.1, < 7.2) | ||
| rswag-specs (2.13.0) | ||
| activesupport (>= 3.1, < 7.2) | ||
| json-schema (>= 2.2, < 5.0) | ||
| railties (>= 3.1, < 7.2) | ||
| rswag-api (2.16.0) | ||
| activesupport (>= 5.2, < 8.1) | ||
| railties (>= 5.2, < 8.1) | ||
| rswag-specs (2.16.0) | ||
| activesupport (>= 5.2, < 8.1) | ||
| json-schema (>= 2.2, < 6.0) | ||
| railties (>= 5.2, < 8.1) | ||
| rspec-core (>= 2.14) | ||
| rswag-ui (2.13.0) | ||
| actionpack (>= 3.1, < 7.2) | ||
| railties (>= 3.1, < 7.2) | ||
| rswag-ui (2.16.0) | ||
| actionpack (>= 5.2, < 8.1) | ||
| railties (>= 5.2, < 8.1) | ||
| rubocop (1.59.0) | ||
@@ -390,4 +395,5 @@ json (~> 2.3) | ||
| ruby2_keywords (0.0.5) | ||
| securerandom (0.4.1) | ||
| spring (4.1.3) | ||
| sqlite3 (1.7.0-x86_64-linux) | ||
| sqlite3 (2.7.3-x86_64-linux-gnu) | ||
| stringio (3.1.0) | ||
@@ -404,2 +410,4 @@ thor (1.3.0) | ||
| parser (>= 3.2.2.4) | ||
| uri (1.0.3) | ||
| useragent (0.16.11) | ||
| webrick (1.8.1) | ||
@@ -415,2 +423,3 @@ websocket-driver (0.7.6) | ||
| DEPENDENCIES | ||
| generator_spec | ||
| rrx_api! | ||
@@ -417,0 +426,0 @@ rrx_dev! |
+1
-1
| # frozen_string_literal: true | ||
| require_relative 'rrx_api/version' | ||
| require_relative 'rrx_api/railtie' | ||
| require_relative 'rrx_api/engine' | ||
| require 'rrx_config' | ||
@@ -6,0 +6,0 @@ require 'rrx_logging' |
| # frozen_string_literal: true | ||
| module RrxApi | ||
| VERSION = "0.1.0" | ||
| RAILS_VERSION = "~> 7.0" | ||
| VERSION = '8.0.2' | ||
| DEPENDENCY_VERSION = "~> #{VERSION}" | ||
| RAILS_VERSION = DEPENDENCY_VERSION | ||
| end |
+1
-1
@@ -28,3 +28,3 @@ # RrxApi | ||
| ```shell | ||
| $ rrx_api_setup | ||
| $ rrx_api | ||
| ``` | ||
@@ -31,0 +31,0 @@ |
| # Default ignored files | ||
| /shelf/ | ||
| /workspace.xml | ||
| # Editor-based HTTP Client requests | ||
| /httpRequests/ | ||
| # Datasource local storage ignored files | ||
| /dataSources/ | ||
| /dataSources.local.xml |
| <component name="InspectionProjectProfileManager"> | ||
| <profile version="1.0"> | ||
| <option name="myName" value="Project Default" /> | ||
| <inspection_tool class="RbsMissingTypeSignature" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> | ||
| </profile> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectModuleManager"> | ||
| <modules> | ||
| <module fileurl="file://$PROJECT_DIR$/.idea/rrx_api.iml" filepath="$PROJECT_DIR$/.idea/rrx_api.iml" /> | ||
| </modules> | ||
| </component> | ||
| </project> |
Sorry, the diff of this file is not supported yet
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="VcsDirectoryMappings"> | ||
| <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||
| </component> | ||
| </project> |
Sorry, the diff of this file is not supported yet
| require 'rack/cors' | ||
| LOCALHOST_PATTERN = /\Ahttp:\/\/localhost(?::\d{4})?\z/.freeze | ||
| Rails.application.config.middleware.insert_before 0, Rack::Cors do | ||
| allow do | ||
| origins do |source, env| | ||
| if Rails.env.development? | ||
| LOCALHOST_PATTERN.match? source | ||
| else | ||
| # TODO | ||
| true | ||
| end | ||
| end | ||
| resource '*', | ||
| headers: :any, | ||
| credentials: true, | ||
| methods: [:get, :post, :put, :patch, :delete, :options, :head] | ||
| end | ||
| end |
| # frozen_string_literal: true | ||
| Rails.application.config.generators do |g| | ||
| g.orm :active_record, primary_key_type: :uuid | ||
| end | ||
| require 'rails' | ||
| require 'active_model/railtie' | ||
| require 'active_record/railtie' | ||
| require 'action_controller/railtie' | ||
| require 'action_text/engine' | ||
| require 'action_view/railtie' | ||
| require 'jbuilder' | ||
| require 'rack/cors' | ||
| require 'actionpack/action_caching' | ||
| module RrxApi | ||
| class Railtie < ::Rails::Engine | ||
| initializer 'rrx.api_docs_config', before: :load_config_initializers do |_app| | ||
| Rails.configuration.api_docs = { 'API' => 'swagger.yaml' } | ||
| end | ||
| initializer 'rrx.api_docs', after: :load_config_initializers do |app| | ||
| # Setup Swagger endpoints if docs exist | ||
| if swagger_root? | ||
| require 'rswag/api' | ||
| require 'rswag/ui' | ||
| Rswag::Api.configure do |c| | ||
| c.swagger_root = Rails.root.join('swagger') | ||
| end | ||
| Rswag::Ui.configure do |c| | ||
| app.config.api_docs.each_pair do |name, file| | ||
| c.swagger_endpoint "/api-docs/#{file}", name | ||
| end | ||
| end | ||
| end | ||
| end | ||
| private | ||
| def swagger_root | ||
| @swagger_root ||= Rails.root.join('swagger') | ||
| end | ||
| def swagger_root? | ||
| swagger_root.exist? | ||
| end | ||
| end | ||
| end |
Sorry, the diff of this file is not supported yet