Repository: ohbarye/rails-react-typescript-docker-example Branch: main Commit: 0d4325119354 Files: 99 Total size: 54.6 KB Directory structure: gitextract_vbzc0pcq/ ├── .gitattributes ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ ├── backend_test.yml │ └── frontend_test.yml ├── .gitignore ├── README.md ├── backend/ │ ├── .gitignore │ ├── .ruby-version │ ├── Dockerfile │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── Rakefile │ ├── app/ │ │ ├── assets/ │ │ │ ├── config/ │ │ │ │ └── manifest.js │ │ │ ├── images/ │ │ │ │ └── .keep │ │ │ ├── javascripts/ │ │ │ │ ├── application.js │ │ │ │ ├── cable.js │ │ │ │ └── channels/ │ │ │ │ └── .keep │ │ │ └── stylesheets/ │ │ │ └── application.css │ │ ├── channels/ │ │ │ └── application_cable/ │ │ │ ├── channel.rb │ │ │ └── connection.rb │ │ ├── controllers/ │ │ │ ├── application_controller.rb │ │ │ ├── concerns/ │ │ │ │ └── .keep │ │ │ └── greetings_controller.rb │ │ ├── helpers/ │ │ │ └── application_helper.rb │ │ ├── jobs/ │ │ │ └── application_job.rb │ │ ├── mailers/ │ │ │ └── application_mailer.rb │ │ ├── models/ │ │ │ ├── application_record.rb │ │ │ └── concerns/ │ │ │ └── .keep │ │ └── views/ │ │ └── layouts/ │ │ ├── application.html.erb │ │ ├── mailer.html.erb │ │ └── mailer.text.erb │ ├── bin/ │ │ ├── bundle │ │ ├── rails │ │ ├── rake │ │ ├── setup │ │ ├── spring │ │ ├── update │ │ └── yarn │ ├── config/ │ │ ├── application.rb │ │ ├── boot.rb │ │ ├── cable.yml │ │ ├── credentials.yml.enc │ │ ├── database.yml │ │ ├── environment.rb │ │ ├── environments/ │ │ │ ├── development.rb │ │ │ ├── production.rb │ │ │ └── test.rb │ │ ├── initializers/ │ │ │ ├── application_controller_renderer.rb │ │ │ ├── assets.rb │ │ │ ├── backtrace_silencers.rb │ │ │ ├── content_security_policy.rb │ │ │ ├── cookies_serializer.rb │ │ │ ├── filter_parameter_logging.rb │ │ │ ├── inflections.rb │ │ │ ├── mime_types.rb │ │ │ ├── new_framework_defaults_6_0.rb │ │ │ └── wrap_parameters.rb │ │ ├── locales/ │ │ │ └── en.yml │ │ ├── puma.rb │ │ ├── routes.rb │ │ ├── spring.rb │ │ └── storage.yml │ ├── config.ru │ ├── db/ │ │ ├── schema.rb │ │ └── seeds.rb │ ├── lib/ │ │ ├── assets/ │ │ │ └── .keep │ │ └── tasks/ │ │ └── .keep │ ├── log/ │ │ └── .keep │ ├── prehook │ ├── public/ │ │ ├── 404.html │ │ ├── 422.html │ │ ├── 500.html │ │ └── robots.txt │ ├── test/ │ │ ├── application_system_test_case.rb │ │ ├── controllers/ │ │ │ └── .keep │ │ ├── fixtures/ │ │ │ ├── .keep │ │ │ └── files/ │ │ │ └── .keep │ │ ├── helpers/ │ │ │ └── .keep │ │ ├── integration/ │ │ │ └── .keep │ │ ├── mailers/ │ │ │ └── .keep │ │ ├── models/ │ │ │ └── .keep │ │ ├── routing/ │ │ │ └── routing_test.rb │ │ ├── system/ │ │ │ └── .keep │ │ └── test_helper.rb │ └── vendor/ │ └── .keep ├── docker-compose.yml └── frontend/ ├── .gitignore ├── jest.config.js ├── package.json ├── src/ │ ├── App.css │ ├── App.tsx │ ├── __tests__/ │ │ ├── App.test.tsx │ │ └── styleMock.js │ ├── index.css │ ├── index.html │ └── index.tsx ├── tsconfig.json └── webpack.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ backend/bin/* eol=lf prehook eol=lf ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: bundler directory: "/backend" schedule: interval: daily time: "20:00" open-pull-requests-limit: 10 ignore: - dependency-name: rails versions: - 6.1.2 - 6.1.2.1 - dependency-name: puma versions: - 5.2.1 - dependency-name: bootsnap versions: - 1.6.0 - package-ecosystem: npm directory: "/frontend" schedule: interval: daily time: "20:00" open-pull-requests-limit: 10 ================================================ FILE: .github/workflows/backend_test.yml ================================================ name: Backend Test on: [push] jobs: test: runs-on: ubuntu-latest defaults: run: working-directory: ./backend services: postgres: image: postgres:11 ports: - 5432:5432 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password POSTGRES_DB: test options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 env: RAILS_ENV: test RAILS_DATABASE_HOST: 127.0.0.1 RAILS_DATABASE_USER: postgres RAILS_DATABASE_PASSWORD: password steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.3.1 bundler-cache: true working-directory: ./backend - name: Migration run: | bundle exec rails db:create bundle exec rake db:schema:load - name: Run rspec run: bundle exec rake test ================================================ FILE: .github/workflows/frontend_test.yml ================================================ name: Frontend Test on: [push] jobs: test: runs-on: ubuntu-latest defaults: run: working-directory: ./frontend steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: "14" - name: Install dependencies run: yarn install - name: Check TypeScript compiler works well run: yarn typecheck - name: Run test run: yarn test ================================================ FILE: .gitignore ================================================ # See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' # Ignore bundler config. /.bundle # Ignore all logfiles and tempfiles. /log/* /tmp/* */tmp/* !/log/.keep !/tmp/.keep # Ignore uploaded files in development /storage/* /node_modules /yarn-error.log /public/assets .byebug_history # Ignore master key for decrypting credentials and more. /config/master.key ================================================ FILE: README.md ================================================ # Rails-React-TypeScript-Docker Example ![backend_test](https://github.com/ohbarye/rails-react-typescript-docker-example/actions/workflows/backend_test.yml/badge.svg) ![frontend_test](https://github.com/ohbarye/rails-react-typescript-docker-example/actions/workflows/frontend_test.yml/badge.svg) ## TL;DR **Here is an example application with the following modern web technology stacks. With this boilerplate, you can easily start to build your own app.** - [Ruby](https://www.ruby-lang.org/en/) 3.3.1 - [Rails](https://rubyonrails.org/) 6.1.4 - [React.js](https://reactjs.org/) 17.0.1 - [TypeScript](https://www.typescriptlang.org/) 4.3.5 - [Docker](https://docs.docker.com/) - [PostgreSQL](https://www.postgresql.org/) 11 - [GitHub Actions](https://github.com/features/actions) ## Usage ```shell $ git clone https://github.com/ohbarye/rails-react-typescript-docker-example.git && cd rails-react-typescript-docker-example # Setup $ docker-compose run frontend yarn $ docker-compose run backend bin/rails db:create db:migrate # Start $ docker-compose up -d # Open frontend $ open http://localhost:80 # You'll see yaichi page, then click any app # Check backend API $ curl -H 'Host: backend.localhost' http://localhost/greetings/hello ``` ## Motivation Nowadays, I feel like **we need a wide range acknowledgment on web development even if we call ourselves "backend developer" or "frontend developer".** As for my experience, I've been a Rails engineer, I'm but recently working like kinda frontend developer because I spend all of my working time for building an SPA (single page application) built with React + TypeScript. The SPA, Of course, has a backend API, Ruby on Rails connecting PostgreSQL in my case. I use Docker Compose for defining and running multi-container Docker applications because it's not much simple to bootstrap all of applications and middlewares. **Learning each technology itself is not a burden. I rather like learning. But I've thought I'd like to pursue my playground whose tech stacks are virtually same as ones I develop in work.** ## Further Details ### Backend The combination, Rails + PostgreSQL + Docker Compose, is just a result I followed [Docker Compose's official instruction](https://docs.docker.com/compose/rails/). ### Frontend It consist of very thin webpack settings, TypeScript config, and Jest. ================================================ FILE: backend/.gitignore ================================================ # See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' # Ignore bundler config. /.bundle # Ignore all logfiles and tempfiles. /log/* /tmp/* !/log/.keep !/tmp/.keep # Ignore uploaded files in development /storage/* /node_modules /yarn-error.log /public/assets .byebug_history # Ignore master key for decrypting credentials and more. /config/master.key ================================================ FILE: backend/.ruby-version ================================================ 3.3.1 ================================================ FILE: backend/Dockerfile ================================================ FROM --platform=linux/amd64 ruby:3.3.1 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir -p /myapp/backend WORKDIR /myapp/backend COPY Gemfile /myapp/backend/Gemfile COPY Gemfile.lock /myapp/backend/Gemfile.lock RUN bundle install COPY . /myapp/backend ENV ENTRYKIT_VERSION 0.4.0 RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && tar -xvzf entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && rm entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && mv entrykit /bin/entrykit \ && chmod +x /bin/entrykit \ && entrykit --symlink ENTRYPOINT [ \ "prehook", "ruby -v", "--", \ "prehook", "/myapp/backend/prehook", "--"] ================================================ FILE: backend/Gemfile ================================================ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.3.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.1.6' # gem 'rails', '~> 6.0.3' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 5.6' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.11' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 3.0' gem 'listen', '~> 3.7' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Automate routing spec gem 'route_mechanic' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'rack-cors', require: 'rack/cors' ================================================ FILE: backend/LICENSE ================================================ MIT License Copyright (c) 2018 Masato Ohba Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: backend/README.md ================================================ # README This README would normally document whatever steps are necessary to get the application up and running. Things you may want to cover: * Ruby version * System dependencies * Configuration * Database creation * Database initialization * How to run the test suite * Services (job queues, cache servers, search engines, etc.) * Deployment instructions * ... ================================================ FILE: backend/Rakefile ================================================ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require_relative 'config/application' Rails.application.load_tasks ================================================ FILE: backend/app/assets/config/manifest.js ================================================ //= link_tree ../images //= link_directory ../javascripts .js //= link_directory ../stylesheets .css ================================================ FILE: backend/app/assets/images/.keep ================================================ ================================================ FILE: backend/app/assets/javascripts/application.js ================================================ // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's // vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require rails-ujs //= require activestorage //= require turbolinks //= require_tree . ================================================ FILE: backend/app/assets/javascripts/cable.js ================================================ // Action Cable provides the framework to deal with WebSockets in Rails. // You can generate new channels where WebSocket features live using the `rails generate channel` command. // //= require action_cable //= require_self //= require_tree ./channels (function() { this.App || (this.App = {}); App.cable = ActionCable.createConsumer(); }).call(this); ================================================ FILE: backend/app/assets/javascripts/channels/.keep ================================================ ================================================ FILE: backend/app/assets/stylesheets/application.css ================================================ /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's * vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require_tree . *= require_self */ ================================================ FILE: backend/app/channels/application_cable/channel.rb ================================================ module ApplicationCable class Channel < ActionCable::Channel::Base end end ================================================ FILE: backend/app/channels/application_cable/connection.rb ================================================ module ApplicationCable class Connection < ActionCable::Connection::Base end end ================================================ FILE: backend/app/controllers/application_controller.rb ================================================ class ApplicationController < ActionController::Base end ================================================ FILE: backend/app/controllers/concerns/.keep ================================================ ================================================ FILE: backend/app/controllers/greetings_controller.rb ================================================ class GreetingsController < ApplicationController def hello render json: { content: 'Hello from Rails' } end end ================================================ FILE: backend/app/helpers/application_helper.rb ================================================ module ApplicationHelper end ================================================ FILE: backend/app/jobs/application_job.rb ================================================ class ApplicationJob < ActiveJob::Base end ================================================ FILE: backend/app/mailers/application_mailer.rb ================================================ class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' end ================================================ FILE: backend/app/models/application_record.rb ================================================ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end ================================================ FILE: backend/app/models/concerns/.keep ================================================ ================================================ FILE: backend/app/views/layouts/application.html.erb ================================================ Myapp <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= yield %> ================================================ FILE: backend/app/views/layouts/mailer.html.erb ================================================ <%= yield %> ================================================ FILE: backend/app/views/layouts/mailer.text.erb ================================================ <%= yield %> ================================================ FILE: backend/bin/bundle ================================================ #!/usr/bin/env ruby ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') ================================================ FILE: backend/bin/rails ================================================ #!/usr/bin/env ruby load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative "../config/boot" require "rails/commands" ================================================ FILE: backend/bin/rake ================================================ #!/usr/bin/env ruby load File.expand_path("spring", __dir__) require_relative "../config/boot" require "rake" Rake.application.run ================================================ FILE: backend/bin/setup ================================================ #!/usr/bin/env ruby require "fileutils" # path to your application root. APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end FileUtils.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') # Install JavaScript dependencies system! 'bin/yarn' # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" system! 'bin/rails restart' end ================================================ FILE: backend/bin/spring ================================================ #!/usr/bin/env ruby if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) gem "bundler" require "bundler" # Load Spring without loading other gems in the Gemfile, for speed. Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring| Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path gem "spring", spring.version require "spring/binstub" rescue Gem::LoadError # Ignore when Spring is not installed. end end ================================================ FILE: backend/bin/update ================================================ #!/usr/bin/env ruby require 'fileutils' include FileUtils # path to your application root. APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end chdir APP_ROOT do # This script is a way to update your development environment automatically. # Add necessary update steps to this file. puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') # Install JavaScript dependencies if using Yarn # system('bin/yarn') puts "\n== Updating database ==" system! 'bin/rails db:migrate' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" system! 'bin/rails restart' end ================================================ FILE: backend/bin/yarn ================================================ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do yarn = ENV["PATH"].split(File::PATH_SEPARATOR). select { |dir| File.expand_path(dir) != __dir__ }. product(["yarn", "yarn.exe"]). map { |dir, file| File.expand_path(file, dir) }. find { |file| File.executable?(file) } if yarn exec yarn, *ARGV else $stderr.puts "Yarn executable was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 end end ================================================ FILE: backend/config/application.rb ================================================ require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Myapp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.0 # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") config.middleware.insert_before 0, Rack::Cors do allow do origins '*' resource '*', headers: :any, methods: [:get, :post, :options] end end end end ================================================ FILE: backend/config/boot.rb ================================================ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations. ================================================ FILE: backend/config/cable.yml ================================================ development: adapter: async test: adapter: test production: adapter: redis url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: myapp_production ================================================ FILE: backend/config/credentials.yml.enc ================================================ MhFYHHqzWPtI+D4H1TUKngSXfC1tnHJ3ELcJPi5hDCoAQSkwNsBRJBsOfQpHmHpBP7FZscShFFJBzZhu5WI20K7eeQzIKKoID4hnT5Xxkczib1MEWaAKfEkyRfkW6ui5kUwXDzLlZqb2Vz5gw54h+Wc2AHRys4ixR5kIH6mQrFyXM6TJeEZMowRil0f+a035BOrk4lNjmFQc6qe//DyCPAic7waY8iPrp51R00j/OB2I3LuU8MQILyOlkqVi7kinHYs6ATMElw2BpQR3zl7YU7hWgrMkVJY0Ivq0LGKxbTDh1+stIixppM6ycCkmdRdnunvqAFqoHf62AEh/F7aByyLVuT9pbEvjC0baC2k/KHHq2T/BSMeHxoiiE2/9nRw8tyq2pK1ABdW7BkUOJd7JfqSyoV8Uaf+c0jCV--UuHo79qD2WhbY77G--jzfM8cZ45rAvAU5O5X4QhQ== ================================================ FILE: backend/config/database.yml ================================================ # PostgreSQL. Versions 9.1 and up are supported. # # Install the pg driver: # gem install pg # On OS X with Homebrew: # gem install pg -- --with-pg-config=/usr/local/bin/pg_config # On OS X with MacPorts: # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg # Choose the win32 build. # Install PostgreSQL and put its /bin directory on your path. # # Configure Using Gemfile # gem 'pg' # default: &default adapter: postgresql encoding: unicode host: <%= ENV.fetch("RAILS_DATABASE_HOST") { 'postgres' } %> username: <%= ENV.fetch("RAILS_DATABASE_USER") { 'postgres' } %> password: <%= ENV.fetch("RAILS_DATABASE_PASSWORD") { 'password' } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default database: myapp_development # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. # When left blank, postgres will use the default role. This is # the same name as the operating system user that initialized the database. #username: myapp # The password associated with the postgres role (username). #password: # Connect on a TCP socket. Omitted by default since the client uses a # domain socket that doesn't need configuration. Windows does not have # domain sockets, so uncomment these lines. #host: localhost # The TCP port the server listens on. Defaults to 5432. # If your server runs on a different port number, change accordingly. #port: 5432 # Schema search path. The server defaults to $user,public #schema_search_path: myapp,sharedapp,public # Minimum log levels, in increasing order: # debug5, debug4, debug3, debug2, debug1, # log, notice, warning, error, fatal, and panic # Defaults to warning. #min_messages: notice # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: <%= ENV.fetch("POSTGRES_DB") { 'myapp_test' } %> # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: myapp_production username: myapp password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %> ================================================ FILE: backend/config/environment.rb ================================================ # Load the Rails application. require_relative "application" # Initialize the Rails application. Rails.application.initialize! ================================================ FILE: backend/config/environments/development.rb ================================================ require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true end ================================================ FILE: backend/config/environments/production.rb ================================================ require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Include generic and useful information about system operation, but avoid logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "myapp_production" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Log disallowed deprecations. config.active_support.disallowed_deprecation = :log # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false # Inserts middleware to perform automatic connection switching. # The `database_selector` hash is used to pass options to the DatabaseSelector # middleware. The `delay` is used to determine how long to wait after a write # to send a subsequent read to the primary. # # The `database_resolver` class is used by the middleware to determine which # database is appropriate to use based on the time delay. # # The `database_resolver_context` class is used by the middleware to set # timestamps for the last write to the primary. The resolver uses the context # class timestamps to determine how long to wait before reading from the # replica. # # By default Rails will store a last write timestamp in the session. The # DatabaseSelector middleware is designed as such you can define your own # strategy for connection switching and pass that into the middleware through # these configuration options. # config.active_record.database_selector = { delay: 2.seconds } # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end ================================================ FILE: backend/config/environments/test.rb ================================================ require "active_support/core_ext/integer/time" # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. config.cache_classes = false config.action_view.cache_template_loading = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true end ================================================ FILE: backend/config/initializers/application_controller_renderer.rb ================================================ # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do # ApplicationController.renderer.defaults.merge!( # http_host: 'example.org', # https: false # ) # end ================================================ FILE: backend/config/initializers/assets.rb ================================================ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path # Add Yarn node_modules folder to the asset load path. Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) ================================================ FILE: backend/config/initializers/backtrace_silencers.rb ================================================ # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] ================================================ FILE: backend/config/initializers/content_security_policy.rb ================================================ # Be sure to restart your server when you modify this file. # Define an application-wide content security policy # For further information see the following documentation # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy # Rails.application.config.content_security_policy do |policy| # policy.default_src :self, :https # policy.font_src :self, :https, :data # policy.img_src :self, :https, :data # policy.object_src :none # policy.script_src :self, :https # policy.style_src :self, :https # # If you are using webpack-dev-server then specify webpack-dev-server host # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? # # Specify URI for violation reports # # policy.report_uri "/csp-violation-report-endpoint" # end # If you are using UJS then enable automatic nonce generation # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } # Set the nonce only to specific directives # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) # Report CSP violations to a specified URI # For further information see the following documentation: # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only # Rails.application.config.content_security_policy_report_only = true ================================================ FILE: backend/config/initializers/cookies_serializer.rb ================================================ # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. # Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json ================================================ FILE: backend/config/initializers/filter_parameter_logging.rb ================================================ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] ================================================ FILE: backend/config/initializers/inflections.rb ================================================ # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end ================================================ FILE: backend/config/initializers/mime_types.rb ================================================ # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf ================================================ FILE: backend/config/initializers/new_framework_defaults_6_0.rb ================================================ # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 6.0 upgrade. # # Once upgraded flip defaults one by one to migrate to the new default. # # Read the Guide for Upgrading Ruby on Rails for more info on each option. # Don't force requests from old versions of IE to be UTF-8 encoded. # Rails.application.config.action_view.default_enforce_utf8 = false # Embed purpose and expiry metadata inside signed and encrypted # cookies for increased security. # # This option is not backwards compatible with earlier Rails versions. # It's best enabled when your entire app is migrated and stable on 6.0. # Rails.application.config.action_dispatch.use_cookies_with_metadata = true # Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. # Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false # Return false instead of self when enqueuing is aborted from a callback. # Rails.application.config.active_job.return_false_on_aborted_enqueue = true # Send Active Storage analysis and purge jobs to dedicated queues. # Rails.application.config.active_storage.queues.analysis = :active_storage_analysis # Rails.application.config.active_storage.queues.purge = :active_storage_purge # When assigning to a collection of attachments declared via `has_many_attached`, replace existing # attachments instead of appending. Use #attach to add new attachments without replacing existing ones. # Rails.application.config.active_storage.replace_on_assign_to_many = true # Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. # # The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), # will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. # If you send mail in the background, job workers need to have a copy of # MailDeliveryJob to ensure all delivery jobs are processed properly. # Make sure your entire app is migrated and stable on 6.0 before using this setting. # Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" # Enable the same cache key to be reused when the object being cached of type # `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) # of the relation's cache key into the cache version to support recycling cache key. # Rails.application.config.active_record.collection_cache_versioning = true ================================================ FILE: backend/config/initializers/wrap_parameters.rb ================================================ # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end ================================================ FILE: backend/config/locales/en.yml ================================================ # Files in the config/locales directory are used for internationalization # and are automatically loaded by Rails. If you want to use locales other # than English, add the necessary files in this directory. # # To use the locales, use `I18n.t`: # # I18n.t 'hello' # # In views, this is aliased to just `t`: # # <%= t('hello') %> # # To use a different locale, set it with `I18n.locale`: # # I18n.locale = :es # # This would use the information in config/locales/es.yml. # # The following keys must be escaped otherwise they will not be retrieved by # the default I18n backend: # # true, false, on, off, yes, no # # Instead, surround them with single quotes. # # en: # 'true': 'foo' # # To learn more, please read the Rails Internationalization guide # available at https://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" ================================================ FILE: backend/config/puma.rb ================================================ # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count # Specifies the `worker_timeout` threshold that Puma will use to wait before # terminating a worker in development environments. # worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } # Specifies the `pidfile` that Puma will use. pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # # workers ENV.fetch("WEB_CONCURRENCY") { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write # process behavior so workers use less memory. # # preload_app! # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart ================================================ FILE: backend/config/routes.rb ================================================ Rails.application.routes.draw do get 'greetings/hello' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end ================================================ FILE: backend/config/spring.rb ================================================ Spring.watch( ".ruby-version", ".rbenv-vars", "tmp/restart.txt", "tmp/caching-dev.txt" ) ================================================ FILE: backend/config/storage.yml ================================================ test: service: Disk root: <%= Rails.root.join("tmp/storage") %> local: service: Disk root: <%= Rails.root.join("storage") %> # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: # service: S3 # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> # region: us-east-1 # bucket: your_own_bucket # Remember not to checkin your GCS keyfile to a repository # google: # service: GCS # project: your_project # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> # bucket: your_own_bucket # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) # microsoft: # service: AzureStorage # storage_account_name: your_account_name # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> # container: your_container_name # mirror: # service: Mirror # primary: local # mirrors: [ amazon, google, microsoft ] ================================================ FILE: backend/config.ru ================================================ # This file is used by Rack-based servers to start the application. require_relative "config/environment" run Rails.application Rails.application.load_server ================================================ FILE: backend/db/schema.rb ================================================ # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rails # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 0) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" end ================================================ FILE: backend/db/seeds.rb ================================================ # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) ================================================ FILE: backend/lib/assets/.keep ================================================ ================================================ FILE: backend/lib/tasks/.keep ================================================ ================================================ FILE: backend/log/.keep ================================================ ================================================ FILE: backend/prehook ================================================ #!/usr/bin/env bash if [ -e Gemfile ]; then bundle check || bundle install fi if [ -e tmp/pids/server.pid ]; then rm tmp/pids/server.pid fi ================================================ FILE: backend/public/404.html ================================================ The page you were looking for doesn't exist (404)

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

If you are the application owner check the logs for more information.

================================================ FILE: backend/public/422.html ================================================ The change you wanted was rejected (422)

The change you wanted was rejected.

Maybe you tried to change something you didn't have access to.

If you are the application owner check the logs for more information.

================================================ FILE: backend/public/500.html ================================================ We're sorry, but something went wrong (500)

We're sorry, but something went wrong.

If you are the application owner check the logs for more information.

================================================ FILE: backend/public/robots.txt ================================================ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file ================================================ FILE: backend/test/application_system_test_case.rb ================================================ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] end ================================================ FILE: backend/test/controllers/.keep ================================================ ================================================ FILE: backend/test/fixtures/.keep ================================================ ================================================ FILE: backend/test/fixtures/files/.keep ================================================ ================================================ FILE: backend/test/helpers/.keep ================================================ ================================================ FILE: backend/test/integration/.keep ================================================ ================================================ FILE: backend/test/mailers/.keep ================================================ ================================================ FILE: backend/test/models/.keep ================================================ ================================================ FILE: backend/test/routing/routing_test.rb ================================================ class RoutingTest < Minitest::Test include ::RouteMechanic::Testing::Methods def test_that_application_has_correct_routes assert_all_routes end end ================================================ FILE: backend/test/system/.keep ================================================ ================================================ FILE: backend/test/test_helper.rb ================================================ ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... end ================================================ FILE: backend/vendor/.keep ================================================ ================================================ FILE: docker-compose.yml ================================================ version: '3' services: db: container_name: postgres image: postgres:11 volumes: - ./tmp/db:/var/lib/postgresql/data environment: POSTGRES_HOST_AUTH_METHOD: trust backend: container_name: backend platform: linux/amd64 build: ./backend command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ./backend:/myapp/backend depends_on: - db frontend: container_name: frontend platform: linux/amd64 image: "node:14-alpine" user: "node" working_dir: /myapp/frontend volumes: - ./frontend:/myapp/frontend command: "yarn dev" depends_on: - backend yaichi: container_name: yaichi platform: linux/amd64 image: mtsmfm/yaichi:1.5.0 ports: - 80:3000 volumes: - /var/run/docker.sock:/var/run/docker.sock ================================================ FILE: frontend/.gitignore ================================================ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js # testing /coverage # production /build # misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* ================================================ FILE: frontend/jest.config.js ================================================ module.exports = { "roots": [ "./src" ], "transform": { "^.+\\.tsx?$": "ts-jest" }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", "moduleFileExtensions": [ "ts", "tsx", "js", ], moduleNameMapper: { '\\.(css)$': '/src/__tests__/styleMock.js', }, } ================================================ FILE: frontend/package.json ================================================ { "name": "frontend", "version": "1.0.0", "main": "index.js", "license": "MIT", "scripts": { "build": "webpack --mode production", "dev": "webpack-dev-server", "test": "jest", "typecheck": "tsc -p . --noEmit" }, "devDependencies": { "@types/jest": "^27.5.0", "@types/react": "^17.0.40", "@types/react-dom": "^17.0.11", "css-loader": "^3.5.3", "html-webpack-plugin": "^4.5.2", "jest": "^26.6.3", "style-loader": "^1.2.1", "ts-jest": "^26.5.6", "ts-loader": "^7.0.5", "typescript": "^4.6.4", "webpack": "^4.44.2", "webpack-cli": "^3.3.12", "webpack-dev-server": "^4.7.4" }, "dependencies": { "react": "^17.0.2", "react-dom": "^17.0.2" } } ================================================ FILE: frontend/src/App.css ================================================ .App { text-align: center; } .App-logo { animation: App-logo-spin infinite 20s linear; height: 40vmin; pointer-events: none; } .App-header { background-color: #282c34; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(10px + 2vmin); color: white; } .App-link { color: #61dafb; } @keyframes App-logo-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } ================================================ FILE: frontend/src/App.tsx ================================================ import React from 'react'; import './App.css'; const BACKEND_API_URL = process.env.BACKEND_API_URL || 'http://backend.localhost'; const fetchContent = async (updateContent: (content: string) => void) => { const response = await fetch(`${BACKEND_API_URL}/greetings/hello`,{ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, }); const data = await response.json(); updateContent(data.content); }; const App: React.FC = () => { const [content, updateContent] = React.useState('Waiting for a response from Rails...'); React.useEffect(() => { fetchContent(updateContent); }, []); return (

{content}

); } export default App; ================================================ FILE: frontend/src/__tests__/App.test.tsx ================================================ import React from 'react'; import ReactDOM from 'react-dom'; import App from '../App'; it('renders without crashing', () => { const div = document.createElement('div'); ReactDOM.render(, div); ReactDOM.unmountComponentAtNode(div); }); ================================================ FILE: frontend/src/__tests__/styleMock.js ================================================ module.exports = {}; ================================================ FILE: frontend/src/index.css ================================================ body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } ================================================ FILE: frontend/src/index.html ================================================ React App
================================================ FILE: frontend/src/index.tsx ================================================ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; ReactDOM.render(, document.getElementById('root')); ================================================ FILE: frontend/tsconfig.json ================================================ { "compilerOptions": { "target": "es2019", "module": "esnext", "moduleResolution": "node", "jsx": "react", "strict": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true } } ================================================ FILE: frontend/webpack.config.js ================================================ const path = require("path"); const HTMLPlugin = require("html-webpack-plugin"); module.exports = { module: { rules: [ { test: /\.tsx?$/, use: { loader: "ts-loader", options: { transpileOnly: true, }, }, }, { test: /\.css$/i, use: ["style-loader", "css-loader"] }, ], }, resolve: { extensions: [".js", ".ts", ".tsx", ".json", ".mjs", ".wasm"], }, plugins: [ new HTMLPlugin({ template: path.join(__dirname, "src/index.html"), }), ], devServer: { host: '0.0.0.0', port: 3000, disableHostCheck: true, }, };