Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/node_modules
/yarn-error.log

/vendor

.byebug_history

/.idea
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apk add --update tzdata && \

RUN apk add --update --virtual runtime-deps nodejs libffi-dev readline sqlite sqlite-dev

RUN apk add --update --virtual build-deps build-base libc-dev linux-headers libxml2-dev libxslt-dev readline-dev
RUN apk add --update --virtual build-deps build-base libc-dev linux-headers libxml2-dev libxslt-dev readline-dev ruby-dev

WORKDIR /tmp
ADD /Gemfile* ./
Expand Down
44 changes: 22 additions & 22 deletions backend/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,61 @@ git_source(:github) do |repo_name|
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2', '>= 5.2.2'
gem 'railties', '~> 5.2', '>= 5.2.2'
gem 'bootsnap', '~> 1.4', '>= 1.4.1'
gem 'rails', '~> 6.0'
gem 'railties', '~> 6.0'
gem 'bootsnap', '~> 1.4', '>= 1.4.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.13'
gem 'sqlite3', '~> 1.4', '>= 1.4.1'
# Use Puma as the app server
gem 'puma', '~> 3.7'
gem 'puma', '~> 4.1', '>= 4.1.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'sass-rails', '~> 6.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
gem 'uglifier', '~> 4.1', '>= 4.1.20'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
gem 'coffee-rails', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
gem 'turbolinks', '~> 5.2'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'jbuilder', '~> 2.9', '>= 2.9.1'
# Use Redis adapter to run Action Cable in production
gem 'redis', '~> 3.0'
gem 'redis', '~> 4.1', '>= 4.1.2'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1', '>= 3.1.13'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'rack-cors', :require => 'rack/cors'
gem 'rack-cors', '~> 1.0', '>= 1.0.3'

gem 'mongoid', '~> 6.1.0'
gem 'mongoid', '~> 7.1', '>= 7.1.2'

gem 'devise', '~> 4.6', '>= 4.6.1'
gem 'devise', '~> 4.7', '>= 4.7.1'

gem 'gen-data', '~> 0.3.11'

gem 'rest-client', '~> 2.0', '>= 2.0.2'
gem 'rest-client', '~> 2.1'

gem 'jwt', '~> 1.5', '>= 1.5.4'
gem 'jwt', '~> 2.2', '>= 2.2.1'

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]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'capybara', '~> 3.29'
gem 'selenium-webdriver'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '~> 4.0', '>= 4.0.1'
gem 'listen', '~> 3.1', '>= 3.1.5'
# 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'
gem 'spring', '~> 2.1'
gem 'spring-watcher-listen', '~> 2.0', '>= 2.0.1'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
10 changes: 5 additions & 5 deletions backend/bin/setup
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
Expand All @@ -9,8 +8,9 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a starting point to setup your application.
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
Expand All @@ -19,11 +19,11 @@ chdir APP_ROOT do

# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end

puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
Expand Down
11 changes: 0 additions & 11 deletions backend/bin/yarn

This file was deleted.

4 changes: 3 additions & 1 deletion backend/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
Expand All @@ -24,7 +26,7 @@ class Application < Rails::Application
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
config.load_defaults 6.0
config.generators do |g|
g.orm :mongoid
end
Expand Down
6 changes: 2 additions & 4 deletions backend/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# 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.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
Expand All @@ -27,7 +25,7 @@
config.cache_store = :null_store
end

# Store uploaded files on the local file system (see config/storage.yml for options)
# 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.
Expand All @@ -45,7 +43,7 @@
config.active_record.verbose_query_logs = true


# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true

# Use an evented file watcher to asynchronously detect changes in source code,
Expand Down
30 changes: 25 additions & 5 deletions backend/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# 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).
Expand All @@ -29,10 +28,10 @@
# 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)
# 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
# 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.*/ ]
Expand All @@ -50,9 +49,9 @@
# 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)
# 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 = "backend_#{Rails.env}"
# config.active_job.queue_name_prefix = "backend_production"

config.action_mailer.perform_caching = false

Expand Down Expand Up @@ -82,4 +81,25 @@

# 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
18 changes: 10 additions & 8 deletions backend/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 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.

# 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!
config.cache_classes = true

config.cache_classes = false

# 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
Expand All @@ -21,14 +22,15 @@
# 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
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test

config.action_mailer.perform_caching = false
Expand All @@ -41,6 +43,6 @@
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end
45 changes: 45 additions & 0 deletions backend/config/initializers/new_framework_defaults_6_0.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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
2 changes: 1 addition & 1 deletion backend/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
# available at https://guides.rubyonrails.org/i18n.html.

en:
hello: "Hello world"
10 changes: 7 additions & 3 deletions backend/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# 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.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
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 `port` that Puma will listen on to receive requests; default is 3000.
#
Expand All @@ -15,8 +16,11 @@
#
environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/web.pid" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# 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).
Expand Down
12 changes: 6 additions & 6 deletions backend/config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
].each { |path| Spring.watch(path) }
Spring.watch(
".ruby-version",
".rbenv-vars",
"tmp/restart.txt",
"tmp/caching-dev.txt"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)

if table_exists?(:active_storage_blobs)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
end
end
end
Loading