Commit f084ff15ee7f284bf1674a365d7491b4b0a4fc8f

Authored by Samson Rollo Jr
1 parent ce8aca96

OJT21-52: Create base api

  1 +# See https://git-scm.com/docs/gitattributes for more about git attribute files.
  2 +
  3 +# Mark the database schema as having been generated.
  4 +db/schema.rb linguist-generated
  5 +
  6 +
  7 +# Mark any vendored files as having been vendored.
  8 +vendor/* linguist-vendored
... ...
  1 +# See https://help.github.com/articles/ignoring-files for more about ignoring files.
  2 +#
  3 +# If you find yourself ignoring temporary files generated by your text editor
  4 +# or operating system, you probably want to add a global ignore instead:
  5 +# git config --global core.excludesfile '~/.gitignore_global'
  6 +
  7 +# Ignore bundler config.
  8 +/.bundle
  9 +
  10 +# Ignore all logfiles and tempfiles.
  11 +/log/*
  12 +/tmp/*
  13 +!/log/.keep
  14 +!/tmp/.keep
  15 +
  16 +# Ignore pidfiles, but keep the directory.
  17 +/tmp/pids/*
  18 +!/tmp/pids/
  19 +!/tmp/pids/.keep
  20 +
  21 +# Ignore uploaded files in development.
  22 +/storage/*
  23 +!/storage/.keep
  24 +.byebug_history
  25 +
  26 +# Ignore master key for decrypting credentials and more.
  27 +/config/master.key
... ...
  1 +2.6.7
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +source 'https://rubygems.org'
  4 +git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  5 +
  6 +ruby '2.6.7'
  7 +
  8 +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
  9 +gem 'rails', '~> 6.1.4'
  10 +# Use mysql as the database for Active Record
  11 +gem 'mysql2', '~> 0.5'
  12 +# Use Puma as the app server
  13 +gem 'puma', '~> 5.0'
  14 +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  15 +# gem 'jbuilder', '~> 2.7'
  16 +# Use Redis adapter to run Action Cable in production
  17 +# gem 'redis', '~> 4.0'
  18 +# Use Active Model has_secure_password
  19 +# gem 'bcrypt', '~> 3.1.7'
  20 +
  21 +# Use Active Storage variant
  22 +# gem 'image_processing', '~> 1.2'
  23 +
  24 +# Reduces boot times through caching; required in config/boot.rb
  25 +gem 'bootsnap', '>= 1.4.4', require: false
  26 +
  27 +# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
  28 +# gem 'rack-cors'
  29 +
  30 +group :development, :test do
  31 + # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  32 + gem 'byebug', platforms: %i[mri mingw x64_mingw]
  33 +end
  34 +
  35 +group :development do
  36 + gem 'listen', '~> 3.3'
  37 + gem 'rubocop', require: false
  38 + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  39 + gem 'spring'
  40 +end
  41 +
  42 +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
  43 +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
... ...
  1 +GEM
  2 + remote: https://rubygems.org/
  3 + specs:
  4 + actioncable (6.1.4)
  5 + actionpack (= 6.1.4)
  6 + activesupport (= 6.1.4)
  7 + nio4r (~> 2.0)
  8 + websocket-driver (>= 0.6.1)
  9 + actionmailbox (6.1.4)
  10 + actionpack (= 6.1.4)
  11 + activejob (= 6.1.4)
  12 + activerecord (= 6.1.4)
  13 + activestorage (= 6.1.4)
  14 + activesupport (= 6.1.4)
  15 + mail (>= 2.7.1)
  16 + actionmailer (6.1.4)
  17 + actionpack (= 6.1.4)
  18 + actionview (= 6.1.4)
  19 + activejob (= 6.1.4)
  20 + activesupport (= 6.1.4)
  21 + mail (~> 2.5, >= 2.5.4)
  22 + rails-dom-testing (~> 2.0)
  23 + actionpack (6.1.4)
  24 + actionview (= 6.1.4)
  25 + activesupport (= 6.1.4)
  26 + rack (~> 2.0, >= 2.0.9)
  27 + rack-test (>= 0.6.3)
  28 + rails-dom-testing (~> 2.0)
  29 + rails-html-sanitizer (~> 1.0, >= 1.2.0)
  30 + actiontext (6.1.4)
  31 + actionpack (= 6.1.4)
  32 + activerecord (= 6.1.4)
  33 + activestorage (= 6.1.4)
  34 + activesupport (= 6.1.4)
  35 + nokogiri (>= 1.8.5)
  36 + actionview (6.1.4)
  37 + activesupport (= 6.1.4)
  38 + builder (~> 3.1)
  39 + erubi (~> 1.4)
  40 + rails-dom-testing (~> 2.0)
  41 + rails-html-sanitizer (~> 1.1, >= 1.2.0)
  42 + activejob (6.1.4)
  43 + activesupport (= 6.1.4)
  44 + globalid (>= 0.3.6)
  45 + activemodel (6.1.4)
  46 + activesupport (= 6.1.4)
  47 + activerecord (6.1.4)
  48 + activemodel (= 6.1.4)
  49 + activesupport (= 6.1.4)
  50 + activestorage (6.1.4)
  51 + actionpack (= 6.1.4)
  52 + activejob (= 6.1.4)
  53 + activerecord (= 6.1.4)
  54 + activesupport (= 6.1.4)
  55 + marcel (~> 1.0.0)
  56 + mini_mime (>= 1.1.0)
  57 + activesupport (6.1.4)
  58 + concurrent-ruby (~> 1.0, >= 1.0.2)
  59 + i18n (>= 1.6, < 2)
  60 + minitest (>= 5.1)
  61 + tzinfo (~> 2.0)
  62 + zeitwerk (~> 2.3)
  63 + ast (2.4.2)
  64 + bootsnap (1.7.6)
  65 + msgpack (~> 1.0)
  66 + builder (3.2.4)
  67 + byebug (11.1.3)
  68 + concurrent-ruby (1.1.9)
  69 + crass (1.0.6)
  70 + erubi (1.10.0)
  71 + ffi (1.15.3)
  72 + globalid (0.5.1)
  73 + activesupport (>= 5.0)
  74 + i18n (1.8.10)
  75 + concurrent-ruby (~> 1.0)
  76 + listen (3.6.0)
  77 + rb-fsevent (~> 0.10, >= 0.10.3)
  78 + rb-inotify (~> 0.9, >= 0.9.10)
  79 + loofah (2.10.0)
  80 + crass (~> 1.0.2)
  81 + nokogiri (>= 1.5.9)
  82 + mail (2.7.1)
  83 + mini_mime (>= 0.1.1)
  84 + marcel (1.0.1)
  85 + method_source (1.0.0)
  86 + mini_mime (1.1.0)
  87 + minitest (5.14.4)
  88 + msgpack (1.4.2)
  89 + mysql2 (0.5.3)
  90 + nio4r (2.5.7)
  91 + nokogiri (1.11.7-x86_64-linux)
  92 + racc (~> 1.4)
  93 + parallel (1.20.1)
  94 + parser (3.0.2.0)
  95 + ast (~> 2.4.1)
  96 + puma (5.4.0)
  97 + nio4r (~> 2.0)
  98 + racc (1.5.2)
  99 + rack (2.2.3)
  100 + rack-test (1.1.0)
  101 + rack (>= 1.0, < 3)
  102 + rails (6.1.4)
  103 + actioncable (= 6.1.4)
  104 + actionmailbox (= 6.1.4)
  105 + actionmailer (= 6.1.4)
  106 + actionpack (= 6.1.4)
  107 + actiontext (= 6.1.4)
  108 + actionview (= 6.1.4)
  109 + activejob (= 6.1.4)
  110 + activemodel (= 6.1.4)
  111 + activerecord (= 6.1.4)
  112 + activestorage (= 6.1.4)
  113 + activesupport (= 6.1.4)
  114 + bundler (>= 1.15.0)
  115 + railties (= 6.1.4)
  116 + sprockets-rails (>= 2.0.0)
  117 + rails-dom-testing (2.0.3)
  118 + activesupport (>= 4.2.0)
  119 + nokogiri (>= 1.6)
  120 + rails-html-sanitizer (1.3.0)
  121 + loofah (~> 2.3)
  122 + railties (6.1.4)
  123 + actionpack (= 6.1.4)
  124 + activesupport (= 6.1.4)
  125 + method_source
  126 + rake (>= 0.13)
  127 + thor (~> 1.0)
  128 + rainbow (3.0.0)
  129 + rake (13.0.6)
  130 + rb-fsevent (0.11.0)
  131 + rb-inotify (0.10.1)
  132 + ffi (~> 1.0)
  133 + regexp_parser (2.1.1)
  134 + rexml (3.2.5)
  135 + rubocop (1.18.4)
  136 + parallel (~> 1.10)
  137 + parser (>= 3.0.0.0)
  138 + rainbow (>= 2.2.2, < 4.0)
  139 + regexp_parser (>= 1.8, < 3.0)
  140 + rexml
  141 + rubocop-ast (>= 1.8.0, < 2.0)
  142 + ruby-progressbar (~> 1.7)
  143 + unicode-display_width (>= 1.4.0, < 3.0)
  144 + rubocop-ast (1.8.0)
  145 + parser (>= 3.0.1.1)
  146 + ruby-progressbar (1.11.0)
  147 + spring (2.1.1)
  148 + sprockets (4.0.2)
  149 + concurrent-ruby (~> 1.0)
  150 + rack (> 1, < 3)
  151 + sprockets-rails (3.2.2)
  152 + actionpack (>= 4.0)
  153 + activesupport (>= 4.0)
  154 + sprockets (>= 3.0.0)
  155 + thor (1.1.0)
  156 + tzinfo (2.0.4)
  157 + concurrent-ruby (~> 1.0)
  158 + unicode-display_width (2.0.0)
  159 + websocket-driver (0.7.5)
  160 + websocket-extensions (>= 0.1.0)
  161 + websocket-extensions (0.1.5)
  162 + zeitwerk (2.4.2)
  163 +
  164 +PLATFORMS
  165 + x86_64-linux
  166 +
  167 +DEPENDENCIES
  168 + bootsnap (>= 1.4.4)
  169 + byebug
  170 + listen (~> 3.3)
  171 + mysql2 (~> 0.5)
  172 + puma (~> 5.0)
  173 + rails (~> 6.1.4)
  174 + rubocop
  175 + spring
  176 + tzinfo-data
  177 +
  178 +RUBY VERSION
  179 + ruby 2.6.7p197
  180 +
  181 +BUNDLED WITH
  182 + 2.2.23
... ...
  1 +# README
  2 +
  3 +This README would normally document whatever steps are necessary to get the
  4 +application up and running.
  5 +
  6 +Things you may want to cover:
  7 +
  8 +* Ruby version
  9 +
  10 +* System dependencies
  11 +
  12 +* Configuration
  13 +
  14 +* Database creation
  15 +
  16 +* Database initialization
  17 +
  18 +* How to run the test suite
  19 +
  20 +* Services (job queues, cache servers, search engines, etc.)
  21 +
  22 +* Deployment instructions
  23 +
  24 +* ...
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Add your own tasks in files placed in lib/tasks ending in .rake,
  4 +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
  5 +
  6 +require_relative 'config/application'
  7 +
  8 +Rails.application.load_tasks
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +module ApplicationCable
  4 + class Channel < ActionCable::Channel::Base
  5 + end
  6 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +module ApplicationCable
  4 + class Connection < ActionCable::Connection::Base
  5 + end
  6 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +class ApplicationController < ActionController::API
  4 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +class ApplicationJob < ActiveJob::Base
  4 + # Automatically retry jobs that encountered a deadlock
  5 + # retry_on ActiveRecord::Deadlocked
  6 +
  7 + # Most jobs are safe to ignore if the underlying records are no longer available
  8 + # discard_on ActiveJob::DeserializationError
  9 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +class ApplicationMailer < ActionMailer::Base
  4 + default from: 'from@example.com'
  5 + layout 'mailer'
  6 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +class ApplicationRecord < ActiveRecord::Base
  4 + self.abstract_class = true
  5 +end
... ...
  1 +<!DOCTYPE html>
  2 +<html>
  3 + <head>
  4 + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5 + <style>
  6 + /* Email styles need to be inline */
  7 + </style>
  8 + </head>
  9 +
  10 + <body>
  11 + <%= yield %>
  12 + </body>
  13 +</html>
... ...
  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($PROGRAM_NAME) == 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 +
  28 + bundler_version = nil
  29 + update_index = nil
  30 + ARGV.each_with_index do |a, i|
  31 + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
  32 + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
  33 +
  34 + bundler_version = Regexp.last_match(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', __dir__)
  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 +
  59 + lockfile_contents = File.read(lockfile)
  60 + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
  61 +
  62 + Regexp.last_match(1)
  63 + end
  64 +
  65 + def bundler_version
  66 + @bundler_version ||=
  67 + env_var_version || cli_arg_version ||
  68 + lockfile_version
  69 + end
  70 +
  71 + def bundler_requirement
  72 + return "#{Gem::Requirement.default}.a" unless bundler_version
  73 +
  74 + bundler_gem_version = Gem::Version.new(bundler_version)
  75 +
  76 + requirement = bundler_gem_version.approximate_recommendation
  77 +
  78 + return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.7.0')
  79 +
  80 + requirement += '.a' if bundler_gem_version.prerelease?
  81 +
  82 + requirement
  83 + end
  84 +
  85 + def load_bundler!
  86 + ENV['BUNDLE_GEMFILE'] ||= gemfile
  87 +
  88 + activate_bundler
  89 + end
  90 +
  91 + def activate_bundler
  92 + gem_error = activation_error_handling do
  93 + gem 'bundler', bundler_requirement
  94 + end
  95 + return if gem_error.nil?
  96 +
  97 + require_error = activation_error_handling do
  98 + require 'bundler/version'
  99 + end
  100 + if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
  101 + return
  102 + end
  103 +
  104 + 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}'`"
  105 + exit 42
  106 + end
  107 +
  108 + def activation_error_handling
  109 + yield
  110 + nil
  111 + rescue StandardError, LoadError => e
  112 + e
  113 + end
  114 +end
  115 +
  116 +m.load_bundler!
  117 +
  118 +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?
... ...
  1 +#!/usr/bin/env ruby
  2 +# frozen_string_literal: true
  3 +
  4 +load File.expand_path('spring', __dir__)
  5 +APP_PATH = File.expand_path('../config/application', __dir__)
  6 +require_relative '../config/boot'
  7 +require 'rails/commands'
... ...
  1 +#!/usr/bin/env ruby
  2 +# frozen_string_literal: true
  3 +
  4 +load File.expand_path('spring', __dir__)
  5 +require_relative '../config/boot'
  6 +require 'rake'
  7 +Rake.application.run
... ...
  1 +#!/usr/bin/env ruby
  2 +# frozen_string_literal: true
  3 +
  4 +require 'fileutils'
  5 +
  6 +# path to your application root.
  7 +APP_ROOT = File.expand_path('..', __dir__)
  8 +
  9 +def system!(*args)
  10 + system(*args) || abort("\n== Command #{args} failed ==")
  11 +end
  12 +
  13 +FileUtils.chdir APP_ROOT do
  14 + # This script is a way to set up or update your development environment automatically.
  15 + # This script is idempotent, so that you can run it at any time and get an expectable outcome.
  16 + # Add necessary setup steps to this file.
  17 +
  18 + puts '== Installing dependencies =='
  19 + system! 'gem install bundler --conservative'
  20 + system('bundle check') || system!('bundle install')
  21 +
  22 + # puts "\n== Copying sample files =="
  23 + # unless File.exist?('config/database.yml')
  24 + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
  25 + # end
  26 +
  27 + puts "\n== Preparing database =="
  28 + system! 'bin/rails db:prepare'
  29 +
  30 + puts "\n== Removing old logs and tempfiles =="
  31 + system! 'bin/rails log:clear tmp:clear'
  32 +
  33 + puts "\n== Restarting application server =="
  34 + system! 'bin/rails restart'
  35 +end
... ...
  1 +#!/usr/bin/env ruby
  2 +# frozen_string_literal: true
  3 +
  4 +if !defined?(Spring) && [nil, 'development', 'test'].include?(ENV['RAILS_ENV'])
  5 + gem 'bundler'
  6 + require 'bundler'
  7 +
  8 + # Load Spring without loading other gems in the Gemfile, for speed.
  9 + Bundler.locked_gems&.specs&.find { |spec| spec.name == 'spring' }&.tap do |spring|
  10 + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
  11 + gem 'spring', spring.version
  12 + require 'spring/binstub'
  13 + rescue Gem::LoadError
  14 + # Ignore when Spring is not installed.
  15 + end
  16 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# This file is used by Rack-based servers to start the application.
  4 +
  5 +require_relative 'config/environment'
  6 +
  7 +run Rails.application
  8 +Rails.application.load_server
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require_relative 'boot'
  4 +
  5 +require 'rails'
  6 +# Pick the frameworks you want:
  7 +require 'active_model/railtie'
  8 +require 'active_job/railtie'
  9 +require 'active_record/railtie'
  10 +require 'active_storage/engine'
  11 +require 'action_controller/railtie'
  12 +require 'action_mailer/railtie'
  13 +require 'action_mailbox/engine'
  14 +require 'action_text/engine'
  15 +require 'action_view/railtie'
  16 +require 'action_cable/engine'
  17 +# require "sprockets/railtie"
  18 +require 'rails/test_unit/railtie'
  19 +
  20 +# Require the gems listed in Gemfile, including any gems
  21 +# you've limited to :test, :development, or :production.
  22 +Bundler.require(*Rails.groups)
  23 +
  24 +module AutoLogsApi
  25 + class Application < Rails::Application
  26 + # Initialize configuration defaults for originally generated Rails version.
  27 + config.load_defaults 6.1
  28 +
  29 + # Configuration for the application, engines, and railties goes here.
  30 + #
  31 + # These settings can be overridden in specific environments using the files
  32 + # in config/environments, which are processed later.
  33 + #
  34 + # config.time_zone = "Central Time (US & Canada)"
  35 + # config.eager_load_paths << Rails.root.join("extras")
  36 +
  37 + # Only loads a smaller set of middleware suitable for API only apps.
  38 + # Middleware like session, flash, cookies can be added back manually.
  39 + # Skip views, helpers and assets when generating a new resource.
  40 + config.api_only = true
  41 + end
  42 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
  4 +
  5 +require 'bundler/setup' # Set up gems listed in the Gemfile.
  6 +require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
... ...
  1 +development:
  2 + adapter: async
  3 +
  4 +test:
  5 + adapter: test
  6 +
  7 +production:
  8 + adapter: redis
  9 + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
  10 + channel_prefix: auto_logs_api_production
... ...
  1 +7IoPiCaIHJlRC+PokQLmuElxsLUDQk8rtAqYLrw+miHx52+l5z4Hdj6AUluMH7kcJEfymUwGLSjOnWaDa8aUR7L9oUa6u7umYMgQKnftcZzFvVHy0wBYhlZc8qRgXY90pkaaNHEbdKN1hqtNcGZGOHZbcUHl2NX29epA2dBNwd0rH0hJOVbRmRWqQrQx2FAOX/ufOblhO4LcnxRJ+HYN2VnvnljfgmDPfw3r22AxEXwSooCn2ffSy7otDPW1KXiXaT1JNbl6UyL8lTCFxftgX0pAmHoi680t1eeNTycFTssIdxxEVApz0ukS0V/d8cRCuGe/jRHJOHx2aCSRP9md81z2rvlVT0NBoxQJimyodKAkXxjW3t0Kql/3gME8s/Rz4xPjO3u1Ac2w5ghLRvsIhg+pI0cj+KvpCeSX--tqm8u176lwCPbFj5--4x0tomj4ckKqlW3UQ9buFw==
\ No newline at end of file
... ...
  1 +# MySQL. Versions 5.5.8 and up are supported.
  2 +#
  3 +# Install the MySQL driver
  4 +# gem install mysql2
  5 +#
  6 +# Ensure the MySQL gem is defined in your Gemfile
  7 +# gem 'mysql2'
  8 +#
  9 +# And be sure to use new-style password hashing:
  10 +# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
  11 +#
  12 +default: &default
  13 + adapter: mysql2
  14 + encoding: utf8mb4
  15 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  16 + username: <%= ENV['MYSQL_USERNAME']%>
  17 + password: <%= ENV['MYSQL_PASSWORD']%>
  18 + socket: /var/run/mysqld/mysqld.sock
  19 +
  20 +development:
  21 + <<: *default
  22 + database: auto_logs_api_development
  23 +
  24 +# Warning: The database defined as "test" will be erased and
  25 +# re-generated from your development database when you run "rake".
  26 +# Do not set this db to the same as development or production.
  27 +test:
  28 + <<: *default
  29 + database: auto_logs_api_test
  30 +
  31 +# As with config/credentials.yml, you never want to store sensitive information,
  32 +# like your database password, in your source code. If your source code is
  33 +# ever seen by anyone, they now have access to your database.
  34 +#
  35 +# Instead, provide the password or a full connection URL as an environment
  36 +# variable when you boot the app. For example:
  37 +#
  38 +# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
  39 +#
  40 +# If the connection URL is provided in the special DATABASE_URL environment
  41 +# variable, Rails will automatically merge its configuration values on top of
  42 +# the values provided in this file. Alternatively, you can specify a connection
  43 +# URL environment variable explicitly:
  44 +#
  45 +# production:
  46 +# url: <%= ENV['MY_APP_DATABASE_URL'] %>
  47 +#
  48 +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
  49 +# for a full overview on how database connection configuration can be specified.
  50 +#
  51 +production:
  52 + <<: *default
  53 + database: auto_logs_api_production
  54 + username: auto_logs_api
  55 + password: <%= ENV['AUTO_LOGS_API_DATABASE_PASSWORD'] %>
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Load the Rails application.
  4 +require_relative 'application'
  5 +
  6 +# Load the app's custom environment variables here, so that they are loaded before environments/*.rb
  7 +mysql_account = File.join(Rails.root, 'config', 'mysql_account.rb')
  8 +load(mysql_account) if File.exist?(mysql_account)
  9 +
  10 +# Initialize the Rails application.
  11 +Rails.application.initialize!
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require 'active_support/core_ext/integer/time'
  4 +
  5 +Rails.application.configure do
  6 + # Settings specified here will take precedence over those in config/application.rb.
  7 +
  8 + # In the development environment your application's code is reloaded any time
  9 + # it changes. This slows down response time but is perfect for development
  10 + # since you don't have to restart the web server when you make code changes.
  11 + config.cache_classes = false
  12 +
  13 + # Do not eager load code on boot.
  14 + config.eager_load = false
  15 +
  16 + # Show full error reports.
  17 + config.consider_all_requests_local = true
  18 +
  19 + # Enable/disable caching. By default caching is disabled.
  20 + # Run rails dev:cache to toggle caching.
  21 + if Rails.root.join('tmp', 'caching-dev.txt').exist?
  22 + config.cache_store = :memory_store
  23 + config.public_file_server.headers = {
  24 + 'Cache-Control' => "public, max-age=#{2.days.to_i}"
  25 + }
  26 + else
  27 + config.action_controller.perform_caching = false
  28 +
  29 + config.cache_store = :null_store
  30 + end
  31 +
  32 + # Store uploaded files on the local file system (see config/storage.yml for options).
  33 + config.active_storage.service = :local
  34 +
  35 + # Don't care if the mailer can't send.
  36 + config.action_mailer.raise_delivery_errors = false
  37 +
  38 + config.action_mailer.perform_caching = false
  39 +
  40 + # Print deprecation notices to the Rails logger.
  41 + config.active_support.deprecation = :log
  42 +
  43 + # Raise exceptions for disallowed deprecations.
  44 + config.active_support.disallowed_deprecation = :raise
  45 +
  46 + # Tell Active Support which deprecation messages to disallow.
  47 + config.active_support.disallowed_deprecation_warnings = []
  48 +
  49 + # Raise an error on page load if there are pending migrations.
  50 + config.active_record.migration_error = :page_load
  51 +
  52 + # Highlight code that triggered database queries in logs.
  53 + config.active_record.verbose_query_logs = true
  54 +
  55 + # Raises error for missing translations.
  56 + # config.i18n.raise_on_missing_translations = true
  57 +
  58 + # Annotate rendered view with file names.
  59 + # config.action_view.annotate_rendered_view_with_filenames = true
  60 +
  61 + # Use an evented file watcher to asynchronously detect changes in source code,
  62 + # routes, locales, etc. This feature depends on the listen gem.
  63 + config.file_watcher = ActiveSupport::EventedFileUpdateChecker
  64 +
  65 + # Uncomment if you wish to allow Action Cable access from any origin.
  66 + # config.action_cable.disable_request_forgery_protection = true
  67 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require 'active_support/core_ext/integer/time'
  4 +
  5 +Rails.application.configure do
  6 + # Settings specified here will take precedence over those in config/application.rb.
  7 +
  8 + # Code is not reloaded between requests.
  9 + config.cache_classes = true
  10 +
  11 + # Eager load code on boot. This eager loads most of Rails and
  12 + # your application in memory, allowing both threaded web servers
  13 + # and those relying on copy on write to perform better.
  14 + # Rake tasks automatically ignore this option for performance.
  15 + config.eager_load = true
  16 +
  17 + # Full error reports are disabled and caching is turned on.
  18 + config.consider_all_requests_local = false
  19 +
  20 + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
  21 + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
  22 + # config.require_master_key = true
  23 +
  24 + # Disable serving static files from the `/public` folder by default since
  25 + # Apache or NGINX already handles this.
  26 + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  27 +
  28 + # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  29 + # config.asset_host = 'http://assets.example.com'
  30 +
  31 + # Specifies the header that your server uses for sending files.
  32 + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
  33 + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
  34 +
  35 + # Store uploaded files on the local file system (see config/storage.yml for options).
  36 + config.active_storage.service = :local
  37 +
  38 + # Mount Action Cable outside main process or domain.
  39 + # config.action_cable.mount_path = nil
  40 + # config.action_cable.url = 'wss://example.com/cable'
  41 + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
  42 +
  43 + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  44 + # config.force_ssl = true
  45 +
  46 + # Include generic and useful information about system operation, but avoid logging too much
  47 + # information to avoid inadvertent exposure of personally identifiable information (PII).
  48 + config.log_level = :info
  49 +
  50 + # Prepend all log lines with the following tags.
  51 + config.log_tags = [:request_id]
  52 +
  53 + # Use a different cache store in production.
  54 + # config.cache_store = :mem_cache_store
  55 +
  56 + # Use a real queuing backend for Active Job (and separate queues per environment).
  57 + # config.active_job.queue_adapter = :resque
  58 + # config.active_job.queue_name_prefix = "auto_logs_api_production"
  59 +
  60 + config.action_mailer.perform_caching = false
  61 +
  62 + # Ignore bad email addresses and do not raise email delivery errors.
  63 + # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  64 + # config.action_mailer.raise_delivery_errors = false
  65 +
  66 + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  67 + # the I18n.default_locale when a translation cannot be found).
  68 + config.i18n.fallbacks = true
  69 +
  70 + # Send deprecation notices to registered listeners.
  71 + config.active_support.deprecation = :notify
  72 +
  73 + # Log disallowed deprecations.
  74 + config.active_support.disallowed_deprecation = :log
  75 +
  76 + # Tell Active Support which deprecation messages to disallow.
  77 + config.active_support.disallowed_deprecation_warnings = []
  78 +
  79 + # Use default logging formatter so that PID and timestamp are not suppressed.
  80 + config.log_formatter = ::Logger::Formatter.new
  81 +
  82 + # Use a different logger for distributed setups.
  83 + # require "syslog/logger"
  84 + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
  85 +
  86 + if ENV['RAILS_LOG_TO_STDOUT'].present?
  87 + logger = ActiveSupport::Logger.new($stdout)
  88 + logger.formatter = config.log_formatter
  89 + config.logger = ActiveSupport::TaggedLogging.new(logger)
  90 + end
  91 +
  92 + # Do not dump schema after migrations.
  93 + config.active_record.dump_schema_after_migration = false
  94 +
  95 + # Inserts middleware to perform automatic connection switching.
  96 + # The `database_selector` hash is used to pass options to the DatabaseSelector
  97 + # middleware. The `delay` is used to determine how long to wait after a write
  98 + # to send a subsequent read to the primary.
  99 + #
  100 + # The `database_resolver` class is used by the middleware to determine which
  101 + # database is appropriate to use based on the time delay.
  102 + #
  103 + # The `database_resolver_context` class is used by the middleware to set
  104 + # timestamps for the last write to the primary. The resolver uses the context
  105 + # class timestamps to determine how long to wait before reading from the
  106 + # replica.
  107 + #
  108 + # By default Rails will store a last write timestamp in the session. The
  109 + # DatabaseSelector middleware is designed as such you can define your own
  110 + # strategy for connection switching and pass that into the middleware through
  111 + # these configuration options.
  112 + # config.active_record.database_selector = { delay: 2.seconds }
  113 + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
  114 + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
  115 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require 'active_support/core_ext/integer/time'
  4 +
  5 +# The test environment is used exclusively to run your application's
  6 +# test suite. You never need to work with it otherwise. Remember that
  7 +# your test database is "scratch space" for the test suite and is wiped
  8 +# and recreated between test runs. Don't rely on the data there!
  9 +
  10 +Rails.application.configure do
  11 + # Settings specified here will take precedence over those in config/application.rb.
  12 +
  13 + config.cache_classes = false
  14 + config.action_view.cache_template_loading = true
  15 +
  16 + # Do not eager load code on boot. This avoids loading your whole application
  17 + # just for the purpose of running a single test. If you are using a tool that
  18 + # preloads Rails for running tests, you may have to set it to true.
  19 + config.eager_load = false
  20 +
  21 + # Configure public file server for tests with Cache-Control for performance.
  22 + config.public_file_server.enabled = true
  23 + config.public_file_server.headers = {
  24 + 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
  25 + }
  26 +
  27 + # Show full error reports and disable caching.
  28 + config.consider_all_requests_local = true
  29 + config.action_controller.perform_caching = false
  30 + config.cache_store = :null_store
  31 +
  32 + # Raise exceptions instead of rendering exception templates.
  33 + config.action_dispatch.show_exceptions = false
  34 +
  35 + # Disable request forgery protection in test environment.
  36 + config.action_controller.allow_forgery_protection = false
  37 +
  38 + # Store uploaded files on the local file system in a temporary directory.
  39 + config.active_storage.service = :test
  40 +
  41 + config.action_mailer.perform_caching = false
  42 +
  43 + # Tell Action Mailer not to deliver emails to the real world.
  44 + # The :test delivery method accumulates sent emails in the
  45 + # ActionMailer::Base.deliveries array.
  46 + config.action_mailer.delivery_method = :test
  47 +
  48 + # Print deprecation notices to the stderr.
  49 + config.active_support.deprecation = :stderr
  50 +
  51 + # Raise exceptions for disallowed deprecations.
  52 + config.active_support.disallowed_deprecation = :raise
  53 +
  54 + # Tell Active Support which deprecation messages to disallow.
  55 + config.active_support.disallowed_deprecation_warnings = []
  56 +
  57 + # Raises error for missing translations.
  58 + # config.i18n.raise_on_missing_translations = true
  59 +
  60 + # Annotate rendered view with file names.
  61 + # config.action_view.annotate_rendered_view_with_filenames = true
  62 +end
... ...
  1 +# frozen_string_literal: true
  2 +# Be sure to restart your server when you modify this file.
  3 +
  4 +# ActiveSupport::Reloader.to_prepare do
  5 +# ApplicationController.renderer.defaults.merge!(
  6 +# http_host: 'example.org',
  7 +# https: false
  8 +# )
  9 +# end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Be sure to restart your server when you modify this file.
  4 +
  5 +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  6 +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
  7 +
  8 +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
  9 +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
  10 +Rails.backtrace_cleaner.remove_silencers! if ENV['BACKTRACE']
... ...
  1 +# frozen_string_literal: true
  2 +# Be sure to restart your server when you modify this file.
  3 +
  4 +# Avoid CORS issues when API is called from the frontend app.
  5 +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
  6 +
  7 +# Read more: https://github.com/cyu/rack-cors
  8 +
  9 +# Rails.application.config.middleware.insert_before 0, Rack::Cors do
  10 +# allow do
  11 +# origins 'example.com'
  12 +#
  13 +# resource '*',
  14 +# headers: :any,
  15 +# methods: [:get, :post, :put, :patch, :delete, :options, :head]
  16 +# end
  17 +# end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Be sure to restart your server when you modify this file.
  4 +
  5 +# Configure sensitive parameters which will be filtered from the log file.
  6 +Rails.application.config.filter_parameters += %i[
  7 + passw secret token _key crypt salt certificate otp ssn
  8 +]
... ...
  1 +# frozen_string_literal: true
  2 +# Be sure to restart your server when you modify this file.
  3 +
  4 +# Add new inflection rules using the following format. Inflections
  5 +# are locale specific, and you may define rules for as many different
  6 +# locales as you wish. All of these examples are active by default:
  7 +# ActiveSupport::Inflector.inflections(:en) do |inflect|
  8 +# inflect.plural /^(ox)$/i, '\1en'
  9 +# inflect.singular /^(ox)en/i, '\1'
  10 +# inflect.irregular 'person', 'people'
  11 +# inflect.uncountable %w( fish sheep )
  12 +# end
  13 +
  14 +# These inflection rules are supported but not enabled by default:
  15 +# ActiveSupport::Inflector.inflections(:en) do |inflect|
  16 +# inflect.acronym 'RESTful'
  17 +# end
... ...
  1 +# frozen_string_literal: true
  2 +# Be sure to restart your server when you modify this file.
  3 +
  4 +# Add new mime types for use in respond_to blocks:
  5 +# Mime::Type.register "text/richtext", :rtf
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Be sure to restart your server when you modify this file.
  4 +
  5 +# This file contains settings for ActionController::ParamsWrapper which
  6 +# is enabled by default.
  7 +
  8 +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
  9 +ActiveSupport.on_load(:action_controller) do
  10 + wrap_parameters format: [:json]
  11 +end
  12 +
  13 +# To enable root element in JSON for ActiveRecord objects.
  14 +# ActiveSupport.on_load(:active_record) do
  15 +# self.include_root_in_json = true
  16 +# end
... ...
  1 +# Files in the config/locales directory are used for internationalization
  2 +# and are automatically loaded by Rails. If you want to use locales other
  3 +# than English, add the necessary files in this directory.
  4 +#
  5 +# To use the locales, use `I18n.t`:
  6 +#
  7 +# I18n.t 'hello'
  8 +#
  9 +# In views, this is aliased to just `t`:
  10 +#
  11 +# <%= t('hello') %>
  12 +#
  13 +# To use a different locale, set it with `I18n.locale`:
  14 +#
  15 +# I18n.locale = :es
  16 +#
  17 +# This would use the information in config/locales/es.yml.
  18 +#
  19 +# The following keys must be escaped otherwise they will not be retrieved by
  20 +# the default I18n backend:
  21 +#
  22 +# true, false, on, off, yes, no
  23 +#
  24 +# Instead, surround them with single quotes.
  25 +#
  26 +# en:
  27 +# 'true': 'foo'
  28 +#
  29 +# To learn more, please read the Rails Internationalization guide
  30 +# available at https://guides.rubyonrails.org/i18n.html.
  31 +
  32 +en:
  33 + hello: "Hello world"
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +ENV['MYSQL_USERNAME'] = 'root'
  4 +ENV['MYSQL_USERNAME'] = ''
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# Puma can serve each request in a thread from an internal thread pool.
  4 +# The `threads` method setting takes two numbers: a minimum and maximum.
  5 +# Any libraries that use thread pools should be configured to match
  6 +# the maximum value specified for Puma. Default is set to 5 threads for minimum
  7 +# and maximum; this matches the default thread size of Active Record.
  8 +#
  9 +max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
  10 +min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
  11 +threads min_threads_count, max_threads_count
  12 +
  13 +# Specifies the `worker_timeout` threshold that Puma will use to wait before
  14 +# terminating a worker in development environments.
  15 +#
  16 +worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
  17 +
  18 +# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
  19 +#
  20 +port ENV.fetch('PORT', 3000)
  21 +
  22 +# Specifies the `environment` that Puma will run in.
  23 +#
  24 +environment ENV.fetch('RAILS_ENV', 'development')
  25 +
  26 +# Specifies the `pidfile` that Puma will use.
  27 +pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
  28 +
  29 +# Specifies the number of `workers` to boot in clustered mode.
  30 +# Workers are forked web server processes. If using threads and workers together
  31 +# the concurrency of the application would be max `threads` * `workers`.
  32 +# Workers do not work on JRuby or Windows (both of which do not support
  33 +# processes).
  34 +#
  35 +# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
  36 +
  37 +# Use the `preload_app!` method when specifying a `workers` number.
  38 +# This directive tells Puma to first boot the application and load code
  39 +# before forking the application. This takes advantage of Copy On Write
  40 +# process behavior so workers use less memory.
  41 +#
  42 +# preload_app!
  43 +
  44 +# Allow puma to be restarted by `rails restart` command.
  45 +plugin :tmp_restart
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +Rails.application.routes.draw do
  4 + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
  5 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +Spring.watch(
  4 + '.ruby-version',
  5 + '.rbenv-vars',
  6 + 'tmp/restart.txt',
  7 + 'tmp/caching-dev.txt'
  8 +)
... ...
  1 +test:
  2 + service: Disk
  3 + root: <%= Rails.root.join("tmp/storage") %>
  4 +
  5 +local:
  6 + service: Disk
  7 + root: <%= Rails.root.join("storage") %>
  8 +
  9 +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
  10 +# amazon:
  11 +# service: S3
  12 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
  13 +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
  14 +# region: us-east-1
  15 +# bucket: your_own_bucket
  16 +
  17 +# Remember not to checkin your GCS keyfile to a repository
  18 +# google:
  19 +# service: GCS
  20 +# project: your_project
  21 +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
  22 +# bucket: your_own_bucket
  23 +
  24 +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
  25 +# microsoft:
  26 +# service: AzureStorage
  27 +# storage_account_name: your_account_name
  28 +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
  29 +# container: your_container_name
  30 +
  31 +# mirror:
  32 +# service: Mirror
  33 +# primary: local
  34 +# mirrors: [ amazon, google, microsoft ]
... ...
  1 +# frozen_string_literal: true
  2 +# This file should contain all the record creation needed to seed the database with its default values.
  3 +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
  4 +#
  5 +# Examples:
  6 +#
  7 +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
  8 +# Character.create(name: 'Luke', movie: movies.first)
... ...
  1 +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require 'test_helper'
  4 +
  5 +module ApplicationCable
  6 + class ConnectionTest < ActionCable::Connection::TestCase
  7 + # test "connects with cookies" do
  8 + # cookies.signed[:user_id] = 42
  9 + #
  10 + # connect
  11 + #
  12 + # assert_equal connection.user_id, "42"
  13 + # end
  14 + end
  15 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +ENV['RAILS_ENV'] ||= 'test'
  4 +require_relative '../config/environment'
  5 +require 'rails/test_help'
  6 +
  7 +module ActiveSupport
  8 + class TestCase
  9 + # Run tests in parallel with specified workers
  10 + parallelize(workers: :number_of_processors)
  11 +
  12 + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  13 + fixtures :all
  14 +
  15 + # Add more helper methods to be used by all tests here...
  16 + end
  17 +end
... ...