diff options
| author | realtradam <[email protected]> | 2024-06-27 12:41:26 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-06-27 12:41:26 -0400 |
| commit | c8be5658bae95b94198dc00bd206ba324d9404e0 (patch) | |
| tree | 24563828d9f04a4e52c9187cff3c028434fd886c /rails-backend | |
| parent | 8ec0664fe7cf4a34bc5fc1f162c053622a42dd41 (diff) | |
| download | gameHolster-c8be5658bae95b94198dc00bd206ba324d9404e0.tar.gz gameHolster-c8be5658bae95b94198dc00bd206ba324d9404e0.zip | |
add frontend to repo
Diffstat (limited to 'rails-backend')
119 files changed, 2224 insertions, 0 deletions
diff --git a/rails-backend/.dockerignore b/rails-backend/.dockerignore new file mode 100644 index 0000000..bb56daf --- /dev/null +++ b/rails-backend/.dockerignore @@ -0,0 +1,31 @@ +# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. + +# Ignore git directory. +/.git/ + +# Ignore bundler config. +/.bundle + +# Ignore all environment files (except templates). +/.env* +!/.env*.erb + +# Ignore all default key files. +/config/master.key +/config/credentials/*.key + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/.keep diff --git a/rails-backend/.gitignore b/rails-backend/.gitignore new file mode 100644 index 0000000..752ce8c --- /dev/null +++ b/rails-backend/.gitignore @@ -0,0 +1,37 @@ +# 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 secrets +/config/local_env.yml + +# Ignore bundler config. +/.bundle + +# Ignore all environment files (except templates). +**/.env* +!*/.env*.erb +**/env.toml + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/rails-backend/.ruby-version b/rails-backend/.ruby-version new file mode 100644 index 0000000..fefb2b7 --- /dev/null +++ b/rails-backend/.ruby-version @@ -0,0 +1 @@ +ruby-3.3.3 diff --git a/rails-backend/Dockerfile b/rails-backend/Dockerfile new file mode 100644 index 0000000..e68d5a7 --- /dev/null +++ b/rails-backend/Dockerfile @@ -0,0 +1,63 @@ +# syntax = docker/dockerfile:1 + +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile +ARG RUBY_VERSION=3.3.3 +#FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +FROM registry.docker.com/library/ruby:$RUBY_VERSION-alpine3.20 as base + +# Rails app lives here +WORKDIR /rails + +# Set production environment +ENV RAILS_ENV="production" \ + BUNDLE_DEPLOYMENT="1" \ + BUNDLE_PATH="/usr/local/bundle" \ + BUNDLE_WITHOUT="development" + + +# Throw-away build stage to reduce size of final image +FROM base as build + +# Install packages needed to build gems +#RUN apt-get update -qq && \ +# apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config +RUN apk add --update --no-cache build-base git vips postgresql-libs postgresql-dev tzdata + +# Install application gems +COPY Gemfile Gemfile.lock ./ +RUN bundle install && \ + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ + bundle exec bootsnap precompile --gemfile && echo BLAAAAHHHH + +# Copy application code +COPY . . + +# Precompile bootsnap code for faster boot times +RUN bundle exec bootsnap precompile app/ lib/ + + +# Final stage for app image +FROM base + +# Install packages needed for deployment +#RUN apt-get update -qq && \ +# apt-get install --no-install-recommends -y curl libvips postgresql-client && \ +# rm -rf /var/lib/apt/lists /var/cache/apt/archives +RUN apk add --update --no-cache curl vips postgresql-client + +# Copy built artifacts: gems, application +COPY --from=build /usr/local/bundle /usr/local/bundle +COPY --from=build /rails /rails + +# Run and own only the runtime files as a non-root user for security +#RUN useradd rails --create-home --shell /bin/bash && \ +RUN adduser rails --disabled-password --shell /bin/ash && \ + chown -R rails:rails db log storage tmp +USER rails:rails + +# Entrypoint prepares the database. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] + +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +CMD ["./bin/rails", "server"] diff --git a/rails-backend/Gemfile b/rails-backend/Gemfile new file mode 100644 index 0000000..5b0c3d2 --- /dev/null +++ b/rails-backend/Gemfile @@ -0,0 +1,52 @@ +source "https://rubygems.org" + +ruby "3.3.3" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 7.1.3", ">= 7.1.3.3" + +# Use postgresql as the database for Active Record +gem "pg", "~> 1.1" + +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", ">= 5.0" + +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +# gem "jbuilder" + +# Use Redis adapter to run Action Cable in production +# gem "redis", ">= 4.0.1" + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem "kredis" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data"#, platforms: %i[ windows jruby ] + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +# gem "image_processing", "~> 1.2" + +# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible +gem "rack-cors" + +# Reading TOML files +gem 'tomlib', '~> 0.7.2' + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri windows ] +end + +group :development do + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + # gem "spring" +end + + +gem "rubyzip", "~> 2.3" diff --git a/rails-backend/Gemfile.lock b/rails-backend/Gemfile.lock new file mode 100644 index 0000000..2c89747 --- /dev/null +++ b/rails-backend/Gemfile.lock @@ -0,0 +1,226 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.3.6) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) + marcel (~> 1.0) + activesupport (7.1.3.4) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + base64 (0.2.0) + bcrypt (3.1.20) + bigdecimal (3.1.8) + bootsnap (1.18.3) + msgpack (~> 1.2) + builder (3.3.0) + concurrent-ruby (1.3.3) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + drb (2.2.1) + erubi (1.13.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.13.2) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + mini_mime (1.1.5) + minitest (5.24.0) + msgpack (1.7.2) + mutex_m (0.2.0) + net-imap (0.4.13) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.6-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86-linux) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-linux) + racc (~> 1.4) + pg (1.5.6) + psych (5.1.2) + stringio + puma (6.4.2) + nio4r (~> 2.0) + racc (1.8.0) + rack (3.1.3) + rack-cors (2.0.2) + rack (>= 2.0.0) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + bundler (>= 1.15.0) + railties (= 7.1.3.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + reline (0.5.9) + io-console (~> 0.5) + rubyzip (2.3.2) + stringio (3.1.1) + thor (1.3.1) + timeout (0.4.1) + tomlib (0.7.2) + bigdecimal + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + tzinfo-data (1.2024.1) + tzinfo (>= 1.0.0) + webrick (1.8.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.16) + +PLATFORMS + aarch64-linux + arm-linux + arm64-darwin + x86-linux + x86_64-darwin + x86_64-linux + +DEPENDENCIES + bcrypt (~> 3.1.7) + bootsnap + debug + pg (~> 1.1) + puma (>= 5.0) + rack-cors + rails (~> 7.1.3, >= 7.1.3.3) + rubyzip (~> 2.3) + tomlib (~> 0.7.2) + tzinfo-data + +RUBY VERSION + ruby 3.3.3p89 + +BUNDLED WITH + 2.5.13 diff --git a/rails-backend/README.md b/rails-backend/README.md new file mode 100644 index 0000000..85de49a --- /dev/null +++ b/rails-backend/README.md @@ -0,0 +1,10 @@ +# Game Holster + +Game holster is a full-stack Ruby on Rails and React application for uploading and serving web games made with common game engines such as Unity, Godot, Raylib, and more. + +Currently implemented features in the backend are: +- User authentication: users can log in using GitHub OAuth +- Game Upload: Once a user is logged in they can upload a game which will then belong to them +- Game Serving: Games can be played by users. The games are served under a different domain in order to make XSS attacks impossible in-case a user uploads compromised files. + +The front-end is temporarily my [personal website](https://malcz.com/games) which is made using React. However I am working on a new React frontend in order to have this application be completely standalone and more accessible. diff --git a/rails-backend/Rakefile b/rails-backend/Rakefile new file mode 100644 index 0000000..9a5ea73 --- /dev/null +++ b/rails-backend/Rakefile @@ -0,0 +1,6 @@ +# 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 diff --git a/rails-backend/app/channels/application_cable/channel.rb b/rails-backend/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/rails-backend/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/rails-backend/app/channels/application_cable/connection.rb b/rails-backend/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/rails-backend/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/rails-backend/app/controllers/api/v1/auth_controller.rb b/rails-backend/app/controllers/api/v1/auth_controller.rb new file mode 100644 index 0000000..590be3b --- /dev/null +++ b/rails-backend/app/controllers/api/v1/auth_controller.rb @@ -0,0 +1,109 @@ +require 'net/http' +require 'bcrypt' + +class Api::V1::AuthController < ApplicationController + class << self + end + + def data + if !cookies[:session].nil? + puts cookies[:session] + #render json: Api::V1::AuthController.user_table[cookies[:session]] + result = User.find_by(access_token_digest: cookies[:session]) + puts "--- RESULT: ---" + puts result + render json: result + else + puts "Not logged in" + render json: { info: "Not logged in" }, status: 401 + end + end + def callback + # user logs in through github + # github redirects them to this endpoint with the token in the url as query params + # we need to use this token to exchange with github for user info(i.e username) + #puts "Code: #{params[:code]}" # this is the github token + #puts ENV["GITHUB_CLIENT_SECRET"] + #puts ENV["GITHUB_CLIENT_ID"] + access_token = get_access_token(params[:code]) + user_data = JSON.parse(get_github_user_data(access_token)) + #puts "------------------------- USER DATA: ------------------------- " + #pp user_data + id = user_data['id'].to_s + #puts "id: #{id}, at: #{access_token}" + access_token_digest = BCrypt::Password.create(access_token) + #cookies[:session] = access_token_digest + cookies[:session] = { + value: access_token_digest, + #domain: :all, + #same_site: :none, + secure: true + } + #user_params = { + # # access_token_digest: hashed_token, + # user_data: user_data + #} + #puts "USER DATA HERE NERD" + #puts user_data.class + user = User.find_or_create_by(identifier: id) + user.user_data = user_data + user.access_token_digest = access_token_digest + user.user_name = user_data["login"] + user.save + #redirect_to 'http://localhost:5173/', allow_other_host: true + redirect_to "#{ENV['ROOT_DOMAIN']}/closewindow", allow_other_host: true + end + + private + + def get_github_user_data(access_token) + uri = URI("https://api.github.com/user") + headers = { Authorization: "Bearer #{access_token}" } + response = Net::HTTP.get( + uri, + headers + ) + puts "Response Body" + puts response + #if response.is_a?(Net::HTTPSuccess) + #if response.body.nil? + result = response + if !result["error"].nil? + puts "Error: #{result["error"]}" + puts response + # we had an error + # TODO + else + puts "huh?" if result.nil? + return result + end + #else + # puts "Error(body nil)" + # something went wrong? + # TODO + #end + end + + def get_access_token(github_user_code) + uri = URI("https://github.com/login/oauth/access_token?client_id=#{ENV["GITHUB_CLIENT_ID"]}&client_secret=#{ENV["GITHUB_CLIENT_SECRET"]}&code=#{github_user_code}") + #uri = URI('https://github.com/login/oauth/access_token') + headers = {Accept: 'application/json'} + response = Net::HTTP.post( + uri, + nil, + headers + ) + if response.is_a?(Net::HTTPSuccess) + result = JSON.parse(response.body) + if !result["error"].nil? + # we had an error + else + return result["access_token"] + end + else + # something went wrong? + # TODO + end + end +end + diff --git a/rails-backend/app/controllers/api/v1/games_controller.rb b/rails-backend/app/controllers/api/v1/games_controller.rb new file mode 100644 index 0000000..4346244 --- /dev/null +++ b/rails-backend/app/controllers/api/v1/games_controller.rb @@ -0,0 +1,167 @@ +require "zip" + +class Api::V1::GamesController < ApplicationController + #skip_before_action :verify_authenticity_token + before_action :allow_iframe, only: [:show_file] + def create + puts "----- PARAMS PLATFORM TAG ----------" + pp params["game"]["platform_tag"] + user = User.find_by(access_token_digest: cookies[:session]) + #user = User.first # temporary for debug + if(!user) + render json: {session: cookies[:session]}, status: 401 + else + pp params + + @game = user.games.new(game_params.except(:status, :platform_tag)) + @game.titleSlug = game_params[:title].parameterize + @game.status = game_params[:status].to_i + if !params["game"]["platform_tag"].nil? + params["game"]["platform_tag"].each do |tag| + tag_obj = Tag.find_by(tag_type: "platform", name: tag) + if tag_obj + @game.tags << tag_obj + end + end + end + + @game.save_zip(params[:game][:zip]) + + if @game.save + render json: @game, status: :created + else + render json: @game.errors, status: :unprocessable_entity + end + end + end + + + # list of all games + def index + game = Game.all.order(created_at: :desc) + #render json: game + render json: game.to_json(include: [:game_files, :card_img, :char_img, :title_img, :tags]) + end + + # single game or list of user's games + #get 'games/:user/:game', to: 'games#show' + #get 'games/:user', to: 'games#show' + def show + user = User.find_by! user_name: params[:user] + if params[:game].nil? + # get list of user games + games = Game.where(user_id: user.id).order(created_at: :desc) + render json: games.to_json(include: [:tags]) + else + game = Game.find_by! user_id: user.id, titleSlug: params[:game] + render json: game.to_json(include: [:tags]) + # get game + end + end + + # :user/:game/*path/:file + def show_file + user = User.find_by user_name: params[:user] + + # if no user given then just show all games + if(user.nil?) + game = Game.all.order(created_at: :desc) + render json: game + return + end + + game = Game.find_by user_id: user.id, titleSlug: params[:game] + + # if no game given then just show all games from that user + if(game.nil?) + game = Game.all.order(created_at: :desc) + render json: game + return + end + + # format and file is seperated in rails + filename = params[:file] + if !params[:format].nil? + filename = "#{filename}.#{params[:format]}" + end + + # if we have no path, make it a blank string + # this lets us later match with files that are in the root + params[:path] ||= "" + + result = game.game_files.blobs.find_by(filename: filename, filepath: params[:path].delete_suffix('/').delete_prefix('/')) # TODO check if we need to do the prefix/suffix deletion at all + + # we shouldnt need this + #result ||= game.game_files.blobs.find_by(filename: filename) + if(result.nil?) + game = Game.all.order(created_at: :desc) + render json: { filename: filename, filepath: params[:path] } + #render json: game + return + end + + format = filename.rpartition('.').last + if format == "html" + render html: result.download.html_safe + elsif format == "js" + render js: result.download.html_safe + #else + # redirect_to url_for(result) + #end + elsif format == "gz" + response.headers['Content-Encoding'] = 'gzip' + second_ext = filename.rpartition('.').first.rpartition('.').last + if second_ext == 'js' + send_data result.download.html_safe, filename: filename, disposition: "inline", type: "application/javascript" + elsif second_ext == 'wasm' + send_data result.download.html_safe, filename: filename, disposition: "inline", type: "application/wasm" + elsif second_ext == 'data' + send_data result.download.html_safe, filename: filename, disposition: "inline", type: "application/octet-stream" + else + send_data result.download.html_safe, filename: filename, disposition: "inline" + end + else + send_data result.download.html_safe, filename: filename, disposition: "inline" + end + end + + #get 'imggames/:user/:game?type=___', to: 'games#show_img' + def show_img + user = User.find_by! user_name: params[:user] + game = Game.find_by! user_id: user.id, titleSlug: params[:game] + + result = nil; + if params[:type] == "char" + result = game.char_img.download + elsif params[:type] == "title" + result = game.title_img.download + elsif params[:type] == "card" + result = game.card_img.download + end + + send_data result, type: 'image/png', disposition: 'inline' + end + + private + + def game_params + params.require(:game).permit( + :title, + :description, + :github_link, + :img_rendering, + :status, + :order, + :card_img, + :char_img, + :title_img, + :zip, + :platform_tag + #game_files: [] + ) + end + + def allow_iframe + response.headers.delete('X-Frame-Options') + end +end diff --git a/rails-backend/app/controllers/api/v1/tags_controller.rb b/rails-backend/app/controllers/api/v1/tags_controller.rb new file mode 100644 index 0000000..4b31de8 --- /dev/null +++ b/rails-backend/app/controllers/api/v1/tags_controller.rb @@ -0,0 +1,15 @@ +class Api::V1::TagsController < ApplicationController + + def index + if !params[:tag_type].nil? + tag = Tag.where(tag_type: params[:tag_type]).order(name: :asc) + + render json: tag.to_json + else + tag = Tag.all.order(tag_type: :desc, name: :asc) + #render json: tag + render json: tag.to_json + end + end + +end diff --git a/rails-backend/app/controllers/api/v1/users_controller.rb b/rails-backend/app/controllers/api/v1/users_controller.rb new file mode 100644 index 0000000..ad27ad6 --- /dev/null +++ b/rails-backend/app/controllers/api/v1/users_controller.rb @@ -0,0 +1,10 @@ +class Api::V1::UsersController < ApplicationController + def index + # return list of all users + users = User.all.order(created_at: :desc) + #render json: users.to_json(only: [:name]) + #render json: users.to_json(only: [:user]) + #render json: users.to_json(only: { only: [:name] }) + render json: users.to_json(include: [games: { only: [:title, :titleSlug] }]) + end +end diff --git a/rails-backend/app/controllers/application_controller.rb b/rails-backend/app/controllers/application_controller.rb new file mode 100644 index 0000000..31e16d7 --- /dev/null +++ b/rails-backend/app/controllers/application_controller.rb @@ -0,0 +1,4 @@ +class ApplicationController < ActionController::API + include ActionController::Cookies + include ActionController::RequestForgeryProtection +end diff --git a/rails-backend/app/controllers/concerns/.keep b/rails-backend/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/app/controllers/concerns/.keep diff --git a/rails-backend/app/controllers/platform_tags_controller.rb b/rails-backend/app/controllers/platform_tags_controller.rb new file mode 100644 index 0000000..e3f7392 --- /dev/null +++ b/rails-backend/app/controllers/platform_tags_controller.rb @@ -0,0 +1,8 @@ +class PlatformTagsController < ApplicationController + def index + end + def create + tag = PlatformTag.create!(user_params) + render json: { status: "OK", message: "Tag created" }, status: 201 + end +end diff --git a/rails-backend/app/jobs/application_job.rb b/rails-backend/app/jobs/application_job.rb new file mode 100644 index 0000000..d394c3d --- /dev/null +++ b/rails-backend/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/rails-backend/app/mailers/application_mailer.rb b/rails-backend/app/mailers/application_mailer.rb new file mode 100644 index 0000000..3c34c81 --- /dev/null +++ b/rails-backend/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "[email protected]" + layout "mailer" +end diff --git a/rails-backend/app/models/application_record.rb b/rails-backend/app/models/application_record.rb new file mode 100644 index 0000000..b63caeb --- /dev/null +++ b/rails-backend/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/rails-backend/app/models/concerns/.keep b/rails-backend/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/app/models/concerns/.keep diff --git a/rails-backend/app/models/game.rb b/rails-backend/app/models/game.rb new file mode 100644 index 0000000..e30dfae --- /dev/null +++ b/rails-backend/app/models/game.rb @@ -0,0 +1,39 @@ +require "zip" + +class Game < ApplicationRecord + enum status: { draft: 0, published: 1 } + #enum status: { + # draft: 0, + # published: 1 + #} + belongs_to :user + has_many_attached :game_files + has_one_attached :zip + has_one_attached :card_img + has_one_attached :char_img + has_one_attached :title_img + has_and_belongs_to_many :tags + + def save_zip(zip) + Zip::File.open(zip) do |zipfile| + + zipfile.each do |entry| + if entry.file? + path_name = entry.name.rpartition('/') + name_extension = path_name.last.rpartition('.') + + Tempfile.open([name_extension.first, name_extension[1] + name_extension.last]) do |temp_file| + entry.extract(temp_file.path) { true } + self.game_files.attach(io: File.open(temp_file.path), filename: path_name.last) + self.game_files.last.blob.filepath = path_name.first.delete_suffix('/').delete_prefix('/') + + # saving the game wont have the blob saved so we need to do it manually + self.game_files.last.blob.save + end + + end + end + end + + end +end diff --git a/rails-backend/app/models/tag.rb b/rails-backend/app/models/tag.rb new file mode 100644 index 0000000..e92f654 --- /dev/null +++ b/rails-backend/app/models/tag.rb @@ -0,0 +1,3 @@ +class Tag < ApplicationRecord + has_and_belongs_to_many :users +end diff --git a/rails-backend/app/models/user.rb b/rails-backend/app/models/user.rb new file mode 100644 index 0000000..0dd552d --- /dev/null +++ b/rails-backend/app/models/user.rb @@ -0,0 +1,4 @@ +class User < ApplicationRecord + validates :identifier, presence: true + has_many :games +end diff --git a/rails-backend/app/views/layouts/mailer.html.erb b/rails-backend/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..3aac900 --- /dev/null +++ b/rails-backend/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <style> + /* Email styles need to be inline */ + </style> + </head> + + <body> + <%= yield %> + </body> +</html> diff --git a/rails-backend/app/views/layouts/mailer.text.erb b/rails-backend/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/rails-backend/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/rails-backend/bin/bundle b/rails-backend/bin/bundle new file mode 100755 index 0000000..50da5fd --- /dev/null +++ b/rails-backend/bin/bundle @@ -0,0 +1,109 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($0) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path("../Gemfile", __dir__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) + end + + def bundler_requirement + @bundler_requirement ||= + env_var_version || + cli_arg_version || + bundler_requirement_for(lockfile_version) + end + + def bundler_requirement_for(version) + return "#{Gem::Requirement.default}.a" unless version + + bundler_gem_version = Gem::Version.new(version) + + bundler_gem_version.approximate_recommendation + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + activate_bundler + end + + def activate_bundler + gem_error = activation_error_handling do + gem "bundler", bundler_requirement + end + return if gem_error.nil? + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + 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}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/rails-backend/bin/docker-entrypoint b/rails-backend/bin/docker-entrypoint new file mode 100755 index 0000000..93e0f12 --- /dev/null +++ b/rails-backend/bin/docker-entrypoint @@ -0,0 +1,9 @@ +#!/bin/ash -e + +# If running the rails server then create or migrate existing database +if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then + ./bin/rails db:prepare + ./bin/rails db:seed +fi + +exec "${@}" diff --git a/rails-backend/bin/rails b/rails-backend/bin/rails new file mode 100755 index 0000000..efc0377 --- /dev/null +++ b/rails-backend/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/rails-backend/bin/rake b/rails-backend/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/rails-backend/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/rails-backend/bin/setup b/rails-backend/bin/setup new file mode 100755 index 0000000..3cd5a9d --- /dev/null +++ b/rails-backend/bin/setup @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require "fileutils" + +# path to your application root. +APP_ROOT = File.expand_path("..", __dir__) + +def system!(*args) + system(*args, exception: true) +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") + + # 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 diff --git a/rails-backend/config.ru b/rails-backend/config.ru new file mode 100644 index 0000000..4a3c09a --- /dev/null +++ b/rails-backend/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/rails-backend/config/application.rb b/rails-backend/config/application.rb new file mode 100644 index 0000000..6e54549 --- /dev/null +++ b/rails-backend/config/application.rb @@ -0,0 +1,68 @@ +require_relative "boot" + +require "rails/all" +require 'tomlib' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module GameHolster + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w(assets tasks)) + + # 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") + + # Only loads a smaller set of middleware suitable for API only apps. + # Middleware like session, flash, cookies can be added back manually. + # Skip views, helpers and assets when generating a new resource. + config.api_only = true + + config.middleware.use ActionDispatch::Cookies + config.middleware.use ActionDispatch::Session::CookieStore + + config.active_storage.content_types_allowed_inline << "text/html" + + #localhost:5173 + #config.session_store :cookie_store, key: 'session', domain: :all, tld_length: 5 + + #config.before_configuration do + # env_file = File.join(Rails.root, 'config', 'local_env.yml') + # if File.exist?(env_file) + # YAML.load(File.open(env_file)).each do |key, value| + # ENV[key.to_s] = value + # end + # end + #end + config.before_configuration do + env_file = File.join(Rails.root, 'config', 'env.toml') + if File.exist?(env_file) + env = Tomlib.load(File.read(env_file)) + env['default'].each do |key, value| + ENV[key] = value + end + if Rails.env.production? + env['production'].each do |key, value| + ENV[key] = value + end + elsif Rails.env.development? + env['development'].each do |key, value| + ENV[key] = value + end + end + end + end + end +end diff --git a/rails-backend/config/boot.rb b/rails-backend/config/boot.rb new file mode 100644 index 0000000..988a5dd --- /dev/null +++ b/rails-backend/config/boot.rb @@ -0,0 +1,4 @@ +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. diff --git a/rails-backend/config/cable.yml b/rails-backend/config/cable.yml new file mode 100644 index 0000000..1e98f84 --- /dev/null +++ b/rails-backend/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: new_games_host_production diff --git a/rails-backend/config/credentials.yml.enc b/rails-backend/config/credentials.yml.enc new file mode 100644 index 0000000..fd41b67 --- /dev/null +++ b/rails-backend/config/credentials.yml.enc @@ -0,0 +1 @@ +T1XFG7sWuEQHfdCe2e7DQTtavM2jWD3mgXC/oI/5/Pm+UU6u13d1sMiEmKRGErcuAqGz6C2/jvq0LfpGp8butHtXaRd0O0DESl5gMKqQLbuHpo+8PGjIfDriqcisYMkeQyJ5o/1E0NQbke5oEFXWO2nsHeTkx6+0Ex5fQ3m7ZjUfYAbQKgIuvBTy/XCB1l766BArK08otCJ270PSy24DddB8Gli9QIxLck5V9hU21uKiQ/OCOppYOakORmp9XD/xD6bxhY6heHpeuDjqnfM45+RElP22jS/jDQr+CIu/3H3x3KxPe6ikKHhHev5YBck8aT86dMMYJSsC8BNYI4r+JNJr0aOEVhaMW5KAEElK4rn84a7oPUhRYsY1NSpdbs+fPh9BiGLPoFHrIwYVAAO8M192yjYH--YEVp2SmwYFIjIGOE--MRACW3ors+Sxri+vr1J54A==
\ No newline at end of file diff --git a/rails-backend/config/database.yml b/rails-backend/config/database.yml new file mode 100644 index 0000000..9e43c5b --- /dev/null +++ b/rails-backend/config/database.yml @@ -0,0 +1,87 @@ +# PostgreSQL. Versions 9.3 and up are supported. +# +# Install the pg driver: +# gem install pg +# On macOS with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/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 + # For details on connection pooling, see Rails configuration guide + # https://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + username: <%= ENV["GAMES_HOST_DATABASE_USERNAME"] %> + password: <%= ENV["GAMES_HOST_DATABASE_PASSWORD"] %> + +development: + <<: *default + database: games_host_development + + # The specified database role being used to connect to PostgreSQL. + # To create additional roles in PostgreSQL see `$ createuser --help`. + # When left blank, PostgreSQL will use the default role. This is + # the same name as the operating system user running Rails. + #username: <%= ENV.fetch("GAMES_HOST_DATABASE_USERNAME") %> + + # The password associated with the PostgreSQL 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: games_host_test + +# As with config/credentials.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 or a full connection URL as an environment +# variable when you boot the app. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# If the connection URL is provided in the special DATABASE_URL environment +# variable, Rails will automatically merge its configuration values on top of +# the values provided in this file. Alternatively, you can specify a connection +# URL environment variable explicitly: +# +# production: +# url: <%= ENV["MY_APP_DATABASE_URL"] %> +# +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full overview on how database connection configuration can be specified. +# +production: + <<: *default + database: games_host_production + host: <%= ENV["GAMES_HOST_DATABASE_HOSTNAME"] %> + #username: <%= ENV["GAMES_HOST_DATABASE_USERNAME"] %> + #password: <%= ENV["GAMES_HOST_DATABASE_PASSWORD"] %> diff --git a/rails-backend/config/environment.rb b/rails-backend/config/environment.rb new file mode 100644 index 0000000..cac5315 --- /dev/null +++ b/rails-backend/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/rails-backend/config/environments/development.rb b/rails-backend/config/environments/development.rb new file mode 100644 index 0000000..f962d9f --- /dev/null +++ b/rails-backend/config/environments/development.rb @@ -0,0 +1,71 @@ +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.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = 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.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 + + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = 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 + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/rails-backend/config/environments/production.rb b/rails-backend/config/environments/production.rb new file mode 100644 index 0000000..8f51968 --- /dev/null +++ b/rails-backend/config/environments/production.rb @@ -0,0 +1,90 @@ +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.enable_reloading = false + + # 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 + + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. + # config.public_file_server.enabled = 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.*/ ] + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + config.force_ssl = true + + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + + # 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 = "new_games_host_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 + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +end diff --git a/rails-backend/config/environments/test.rb b/rails-backend/config/environments/test.rb new file mode 100644 index 0000000..adbb4a6 --- /dev/null +++ b/rails-backend/config/environments/test.rb @@ -0,0 +1,64 @@ +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. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # 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 + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # 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 + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/rails-backend/config/initializers/cors.rb b/rails-backend/config/initializers/cors.rb new file mode 100644 index 0000000..541e2ed --- /dev/null +++ b/rails-backend/config/initializers/cors.rb @@ -0,0 +1,27 @@ +# Be sure to restart your server when you modify this file. + +# Avoid CORS issues when API is called from the frontend app. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests. + +# Read more: https://github.com/cyu/rack-cors + +# Rails.application.config.middleware.insert_before 0, Rack::Cors do +# allow do +# origins "example.com" +# +# resource "*", +# headers: :any, +# methods: [:get, :post, :put, :patch, :delete, :options, :head] +# end +# end + + Rails.application.config.middleware.insert_before 0, Rack::Cors do + allow do + origins 'localhost:3000', 'localhost:5173', 'gameshoster.com', 'malcz.com' + + resource '/api/v1/*', + headers: :any, + methods: [:get, :post, :put, :patch, :delete, :options, :head], + credentials: true # <- need this to enable auth + end + end diff --git a/rails-backend/config/initializers/filter_parameter_logging.rb b/rails-backend/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..c2d89e2 --- /dev/null +++ b/rails-backend/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/rails-backend/config/initializers/inflections.rb b/rails-backend/config/initializers/inflections.rb new file mode 100644 index 0000000..3860f65 --- /dev/null +++ b/rails-backend/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# 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 diff --git a/rails-backend/config/locales/en.yml b/rails-backend/config/locales/en.yml new file mode 100644 index 0000000..6c349ae --- /dev/null +++ b/rails-backend/config/locales/en.yml @@ -0,0 +1,31 @@ +# 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. +# +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. +# +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: +# +# en: +# "yes": yup +# enabled: "ON" + +en: + hello: "Hello world" diff --git a/rails-backend/config/puma.rb b/rails-backend/config/puma.rb new file mode 100644 index 0000000..afa809b --- /dev/null +++ b/rails-backend/config/puma.rb @@ -0,0 +1,35 @@ +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. + +# 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 that the worker count should equal the number of processors in production. +if ENV["RAILS_ENV"] == "production" + require "concurrent-ruby" + worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) + workers worker_count if worker_count > 1 +end + +# 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" } + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart diff --git a/rails-backend/config/routes.rb b/rails-backend/config/routes.rb new file mode 100644 index 0000000..ba4c647 --- /dev/null +++ b/rails-backend/config/routes.rb @@ -0,0 +1,46 @@ +Rails.application.routes.draw do + get 'tags/index' + get 'tags/create' + get 'tags/destroy' + # + # isolated domain, do not allow auth here + #constraints host: 'localhost' do + # GAMES + get 'game/:user/:game/*path/:file', to: 'api/v1/games#show_file', constraints: { file: /[^\/]+/ } + get 'game/:user/:game/:file', to: 'api/v1/games#show_file', constraints: { file: /[^\/]+/ } + #end + + namespace :api do + namespace :v1 do + + #constraints host: "localhost" do + # USERS + get 'users/index', to: 'users#index' + + # GAMES + post 'games', to: 'games#create' + get 'games', to: 'games#index' + get 'games/:user/', to: 'games#show' + get 'games/:user/:game', to: 'games#show' + get 'games_img/:user/:game', to: 'games#show_img' + #resources :games + + # TAGS + get 'tags', to: 'tags#index' + + # AUTH + get 'auth/callback', to: 'auth#callback' + get 'auth/data', to: 'auth#data' + #end + + end + end + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get "up" => "rails/health#show", as: :rails_health_check + + # Defines the root path route ("/") + # root "posts#index" +end diff --git a/rails-backend/config/storage.yml b/rails-backend/config/storage.yml new file mode 100644 index 0000000..4942ab6 --- /dev/null +++ b/rails-backend/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/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-<%= Rails.env %> + +# 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-<%= Rails.env %> + +# Use bin/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-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/rails-backend/db/lfs/Games/Almost Pong/card.png b/rails-backend/db/lfs/Games/Almost Pong/card.png Binary files differnew file mode 100644 index 0000000..aab9261 --- /dev/null +++ b/rails-backend/db/lfs/Games/Almost Pong/card.png diff --git a/rails-backend/db/lfs/Games/Almost Pong/character.png b/rails-backend/db/lfs/Games/Almost Pong/character.png Binary files differnew file mode 100644 index 0000000..8e3b3df --- /dev/null +++ b/rails-backend/db/lfs/Games/Almost Pong/character.png diff --git a/rails-backend/db/lfs/Games/Almost Pong/desc.md b/rails-backend/db/lfs/Games/Almost Pong/desc.md new file mode 100644 index 0000000..32756fd --- /dev/null +++ b/rails-backend/db/lfs/Games/Almost Pong/desc.md @@ -0,0 +1,12 @@ +# [Almost Pong](https://github.com/realtradam/almost-pong) + +## Controls +Spacebar to play + +## Tech Stack +Ruby, FelECS, and Raylib + +## Description + +Almost Pong is a silly mashup between the classic Pong and the not so classic Flappy Bird. I saw someone else make this on the internet and I decided to give myself a challenge to see if I could recreate this within a few hours and I did! + diff --git a/rails-backend/db/lfs/Games/Almost Pong/index.zip b/rails-backend/db/lfs/Games/Almost Pong/index.zip Binary files differnew file mode 100644 index 0000000..63a8a2d --- /dev/null +++ b/rails-backend/db/lfs/Games/Almost Pong/index.zip diff --git a/rails-backend/db/lfs/Games/Almost Pong/title.png b/rails-backend/db/lfs/Games/Almost Pong/title.png Binary files differnew file mode 100644 index 0000000..6ee677c --- /dev/null +++ b/rails-backend/db/lfs/Games/Almost Pong/title.png diff --git a/rails-backend/db/lfs/Games/Bubbles, Behind/card.png b/rails-backend/db/lfs/Games/Bubbles, Behind/card.png Binary files differnew file mode 100644 index 0000000..4100514 --- /dev/null +++ b/rails-backend/db/lfs/Games/Bubbles, Behind/card.png diff --git a/rails-backend/db/lfs/Games/Bubbles, Behind/character.png b/rails-backend/db/lfs/Games/Bubbles, Behind/character.png Binary files differnew file mode 100644 index 0000000..3c408c1 --- /dev/null +++ b/rails-backend/db/lfs/Games/Bubbles, Behind/character.png diff --git a/rails-backend/db/lfs/Games/Bubbles, Behind/desc.md b/rails-backend/db/lfs/Games/Bubbles, Behind/desc.md new file mode 100644 index 0000000..90f0975 --- /dev/null +++ b/rails-backend/db/lfs/Games/Bubbles, Behind/desc.md @@ -0,0 +1,20 @@ +# [Bubbles, Behind](https://github.com/realtradam/TOJam2023) + +## Controls + +### Keyboard +- WASD - Movement + +### Controller +Left Joystick - Movement + +## Tech Stack +C and a home-made custom game engine with BGFX + +## Description + +This game was made in 3 days with the collaboration of my friend [Arnold](https://github.com/arngo). We set out to build a game with my woefully unprepared prototype game engine and managed to stick the landing! + +I really enjoy the story on this project because halfway through the project the game engine unexpected brought up a massive bug which made the game entirely unplayable. Luckily through my knowledge of rendering and how I had built up my engine I was able to pinpoint the issue and resolve it before the tight deadline. + +The second interesting thing that happened was a bug which would randomly crash the game after an indeterminate amount of time. This bug had been discovered mere minutes before the deadline however we were able to cover up the bug to players of the game in a very clever way. We set up a bash script which would run in a loop and this script would sleep for a couple seconds and then launch the game. Why would we have a delay to relaunch the game? We set up a full screen window on the PC of an image saying "Game Over". Whenever the game would crash this image would immediately become visible, the players would see it and incorrectly assume they had "died" in the game and then the game would relaunch. The game would launch also in fullscreen so it would go on top of this image. And so no one was aware at all of any bug or crash happening. Hilarious. diff --git a/rails-backend/db/lfs/Games/Bubbles, Behind/index.zip b/rails-backend/db/lfs/Games/Bubbles, Behind/index.zip Binary files differnew file mode 100644 index 0000000..661dac6 --- /dev/null +++ b/rails-backend/db/lfs/Games/Bubbles, Behind/index.zip diff --git a/rails-backend/db/lfs/Games/Bubbles, Behind/title.png b/rails-backend/db/lfs/Games/Bubbles, Behind/title.png Binary files differnew file mode 100644 index 0000000..718918a --- /dev/null +++ b/rails-backend/db/lfs/Games/Bubbles, Behind/title.png diff --git a/rails-backend/db/lfs/Games/Magnet Run/card.png b/rails-backend/db/lfs/Games/Magnet Run/card.png Binary files differnew file mode 100644 index 0000000..5a942da --- /dev/null +++ b/rails-backend/db/lfs/Games/Magnet Run/card.png diff --git a/rails-backend/db/lfs/Games/Magnet Run/character.png b/rails-backend/db/lfs/Games/Magnet Run/character.png Binary files differnew file mode 100644 index 0000000..beb1fbe --- /dev/null +++ b/rails-backend/db/lfs/Games/Magnet Run/character.png diff --git a/rails-backend/db/lfs/Games/Magnet Run/desc.md b/rails-backend/db/lfs/Games/Magnet Run/desc.md new file mode 100644 index 0000000..7d75d1e --- /dev/null +++ b/rails-backend/db/lfs/Games/Magnet Run/desc.md @@ -0,0 +1,16 @@ +# [Magnet Run](https://github.com/realtradam/Magnet-Run-3D) + +## Controls + +- WASD - Movement +- Space - Jump +- Q/E - Rotate camera horizontally(disables auto rotation for a short time) +- Z/X - Rotate camera vertically(disables auto rotation for a short time) + +## Tech Stack +Unity, C# + +## Description + +A 3D Unity game I had created to learn and practice creating a character controller and camera as well as learning how to create a platformer system similar to Super Mario Galaxy where the gravity can be in any direction. + diff --git a/rails-backend/db/lfs/Games/Magnet Run/index.zip b/rails-backend/db/lfs/Games/Magnet Run/index.zip Binary files differnew file mode 100644 index 0000000..4164abe --- /dev/null +++ b/rails-backend/db/lfs/Games/Magnet Run/index.zip diff --git a/rails-backend/db/lfs/Games/Magnet Run/title.png b/rails-backend/db/lfs/Games/Magnet Run/title.png Binary files differnew file mode 100644 index 0000000..b272849 --- /dev/null +++ b/rails-backend/db/lfs/Games/Magnet Run/title.png diff --git a/rails-backend/db/lfs/Games/Optimal Direction/card.png b/rails-backend/db/lfs/Games/Optimal Direction/card.png Binary files differnew file mode 100644 index 0000000..ff6223f --- /dev/null +++ b/rails-backend/db/lfs/Games/Optimal Direction/card.png diff --git a/rails-backend/db/lfs/Games/Optimal Direction/character.png b/rails-backend/db/lfs/Games/Optimal Direction/character.png Binary files differnew file mode 100644 index 0000000..1fd4e20 --- /dev/null +++ b/rails-backend/db/lfs/Games/Optimal Direction/character.png diff --git a/rails-backend/db/lfs/Games/Optimal Direction/desc.md b/rails-backend/db/lfs/Games/Optimal Direction/desc.md new file mode 100644 index 0000000..90febb6 --- /dev/null +++ b/rails-backend/db/lfs/Games/Optimal Direction/desc.md @@ -0,0 +1,18 @@ +# Optimal Direction + +## Controls +- W - Accelerate +- A/D - Steering +- Shift - Drift/Grip +- Space: Brake + +## Tech Stack +Godot + +## Description + +An old overly ambitious project of mine. The goal was to make a sort of realistic 2d racing game where the physics took into account things like weight distribution, front/rear/all wheel drive, gearboxes, etc. + +A lot of those mechanics were implemented, but the scope of the project was much too big for one person at the skill level I was at to realistically finish the project so for that reason it was abandoned. + +I hope to one day revisit this genre again and make a fun game out of it. diff --git a/rails-backend/db/lfs/Games/Optimal Direction/index.zip b/rails-backend/db/lfs/Games/Optimal Direction/index.zip Binary files differnew file mode 100644 index 0000000..4f169ec --- /dev/null +++ b/rails-backend/db/lfs/Games/Optimal Direction/index.zip diff --git a/rails-backend/db/lfs/Games/Optimal Direction/title.png b/rails-backend/db/lfs/Games/Optimal Direction/title.png Binary files differnew file mode 100644 index 0000000..d155fd7 --- /dev/null +++ b/rails-backend/db/lfs/Games/Optimal Direction/title.png diff --git a/rails-backend/db/lfs/Games/Orc: Arena of Time/card.png b/rails-backend/db/lfs/Games/Orc: Arena of Time/card.png Binary files differnew file mode 100644 index 0000000..c757a53 --- /dev/null +++ b/rails-backend/db/lfs/Games/Orc: Arena of Time/card.png diff --git a/rails-backend/db/lfs/Games/Orc: Arena of Time/character.png b/rails-backend/db/lfs/Games/Orc: Arena of Time/character.png Binary files differnew file mode 100644 index 0000000..2e46e51 --- /dev/null +++ b/rails-backend/db/lfs/Games/Orc: Arena of Time/character.png diff --git a/rails-backend/db/lfs/Games/Orc: Arena of Time/desc.md b/rails-backend/db/lfs/Games/Orc: Arena of Time/desc.md new file mode 100644 index 0000000..8072a4e --- /dev/null +++ b/rails-backend/db/lfs/Games/Orc: Arena of Time/desc.md @@ -0,0 +1,15 @@ +# [Orc: Arena of Time](https://github.com/realtradam/orc-arena-of-time) + +## Controls +- WASD - Movement + +## Tech Stack +Ruby, FelECS, and Raylib + +## Description + +Help "Orc", the brave orc, navigate the precarious Arena of Time and prove to all what a mighty adventurer they are! + +In my opinion the best game I have made so far and the one I am the most proud of. It has the most unique gameplay out of all the games I have worked on and a great considerable amount of effort went into this. + +It also won first place overall in the [Raylib 5K gamejam](https://itch.io/jam/raylib-5k-gamejam) which is awesome! diff --git a/rails-backend/db/lfs/Games/Orc: Arena of Time/index.zip b/rails-backend/db/lfs/Games/Orc: Arena of Time/index.zip Binary files differnew file mode 100644 index 0000000..b29fb85 --- /dev/null +++ b/rails-backend/db/lfs/Games/Orc: Arena of Time/index.zip diff --git a/rails-backend/db/lfs/Games/Orc: Arena of Time/title.png b/rails-backend/db/lfs/Games/Orc: Arena of Time/title.png Binary files differnew file mode 100644 index 0000000..311fdb4 --- /dev/null +++ b/rails-backend/db/lfs/Games/Orc: Arena of Time/title.png diff --git a/rails-backend/db/lfs/Games/SpaceCube 64/card.png b/rails-backend/db/lfs/Games/SpaceCube 64/card.png Binary files differnew file mode 100644 index 0000000..2363c7f --- /dev/null +++ b/rails-backend/db/lfs/Games/SpaceCube 64/card.png diff --git a/rails-backend/db/lfs/Games/SpaceCube 64/character.png b/rails-backend/db/lfs/Games/SpaceCube 64/character.png Binary files differnew file mode 100644 index 0000000..11257b7 --- /dev/null +++ b/rails-backend/db/lfs/Games/SpaceCube 64/character.png diff --git a/rails-backend/db/lfs/Games/SpaceCube 64/desc.md b/rails-backend/db/lfs/Games/SpaceCube 64/desc.md new file mode 100644 index 0000000..099657c --- /dev/null +++ b/rails-backend/db/lfs/Games/SpaceCube 64/desc.md @@ -0,0 +1,32 @@ +# [Space Cube 64](https://github.com/realtradam/tojam2024) + +## Controls +### Web Controls: + +#### P1: + +- WASD -> movement +- E -> shoot +- Q -> change camera(thirdperson or firstperson) + +#### P2: +- IJKL -> movement +- O -> shoot +- U -> change camera(thirdperson or firstperson) + + + +### N64 Controls: + +- Joystick -> movement +- Z -> shoot +- R -> change camera(thirdperson or firstperson) + +## Tech Stack +Nintendo 64, C, Libdragon, Raylib + +## Description + +An entry into the Toronto Gamejam 2024, this game was developed for real Nintendo 64 hardware and for the game showcase we demoed the game running on a real Nintendo 64. + +Later we ported this game to the web which is what you can see above and play. It runs significantly better on the web, on the Nintendo the framerate would drop as low at 10fps. diff --git a/rails-backend/db/lfs/Games/SpaceCube 64/index.zip b/rails-backend/db/lfs/Games/SpaceCube 64/index.zip Binary files differnew file mode 100644 index 0000000..ce01311 --- /dev/null +++ b/rails-backend/db/lfs/Games/SpaceCube 64/index.zip diff --git a/rails-backend/db/lfs/Games/SpaceCube 64/title.png b/rails-backend/db/lfs/Games/SpaceCube 64/title.png Binary files differnew file mode 100644 index 0000000..9f306a3 --- /dev/null +++ b/rails-backend/db/lfs/Games/SpaceCube 64/title.png diff --git a/rails-backend/db/lfs/Games/Winter One/card.png b/rails-backend/db/lfs/Games/Winter One/card.png Binary files differnew file mode 100644 index 0000000..d15bc1b --- /dev/null +++ b/rails-backend/db/lfs/Games/Winter One/card.png diff --git a/rails-backend/db/lfs/Games/Winter One/character.png b/rails-backend/db/lfs/Games/Winter One/character.png Binary files differnew file mode 100644 index 0000000..24cfdb1 --- /dev/null +++ b/rails-backend/db/lfs/Games/Winter One/character.png diff --git a/rails-backend/db/lfs/Games/Winter One/desc.md b/rails-backend/db/lfs/Games/Winter One/desc.md new file mode 100644 index 0000000..e392807 --- /dev/null +++ b/rails-backend/db/lfs/Games/Winter One/desc.md @@ -0,0 +1,13 @@ +# Winter One + +## Controls +Mouse + Click + +## Tech Stack +Godot + +## Description + +An old game which we republished onto Itch. This is the first game [Arnold](https://github.com/arngo) and myself have worked on together. Its a pretty simple endless scrolling shooter with 2 different enemy types. We could of developed more but we decided to instead try and move on to a different game. It was supposed to be a short 1-2 week project that ended up taking over 3 weeks to finish. This was mostly a project about learning the ins and and outs of the Godot Engine and also to try an manage a short deadline(winter break). + + diff --git a/rails-backend/db/lfs/Games/Winter One/index.zip b/rails-backend/db/lfs/Games/Winter One/index.zip Binary files differnew file mode 100644 index 0000000..01eb869 --- /dev/null +++ b/rails-backend/db/lfs/Games/Winter One/index.zip diff --git a/rails-backend/db/lfs/Games/Winter One/title.png b/rails-backend/db/lfs/Games/Winter One/title.png Binary files differnew file mode 100644 index 0000000..a654725 --- /dev/null +++ b/rails-backend/db/lfs/Games/Winter One/title.png diff --git a/rails-backend/db/migrate/20240519191604_create_users.rb b/rails-backend/db/migrate/20240519191604_create_users.rb new file mode 100644 index 0000000..d1fa192 --- /dev/null +++ b/rails-backend/db/migrate/20240519191604_create_users.rb @@ -0,0 +1,13 @@ +class CreateUsers < ActiveRecord::Migration[7.1] + def change + create_table :users do |t| + t.string :user_name # we need this for game urls + t.string :identifier + t.string :access_token_digest + t.json :user_data + + t.timestamps + end + #add_index :users, :identifier, unique: true + end +end diff --git a/rails-backend/db/migrate/20240521142838_create_active_storage_tables.active_storage.rb b/rails-backend/db/migrate/20240521142838_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..e4706aa --- /dev/null +++ b/rails-backend/db/migrate/20240521142838_create_active_storage_tables.active_storage.rb @@ -0,0 +1,57 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[7.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :active_storage_blobs, id: primary_key_type do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.string :service_name, null: false + t.bigint :byte_size, null: false + t.string :checksum + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments, id: primary_key_type do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + t.references :blob, null: false, type: foreign_key_type + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + + create_table :active_storage_variant_records, id: primary_key_type do |t| + t.belongs_to :blob, null: false, index: false, type: foreign_key_type + t.string :variation_digest, null: false + + t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end +end diff --git a/rails-backend/db/migrate/20240521205000_create_games.rb b/rails-backend/db/migrate/20240521205000_create_games.rb new file mode 100644 index 0000000..d65b118 --- /dev/null +++ b/rails-backend/db/migrate/20240521205000_create_games.rb @@ -0,0 +1,16 @@ +class CreateGames < ActiveRecord::Migration[7.1] + def change + create_table :games do |t| + t.string :title + t.string :titleSlug + t.string :description + t.string :github_link + t.string :img_rendering + t.integer :status, default: 0 + t.integer :order, default: 0 + + t.timestamps + end + add_reference :games, :user, null: false, foreign_key: true + end +end diff --git a/rails-backend/db/migrate/20240527231908_add_path_to_active_storage_blobs.rb b/rails-backend/db/migrate/20240527231908_add_path_to_active_storage_blobs.rb new file mode 100644 index 0000000..c591ae1 --- /dev/null +++ b/rails-backend/db/migrate/20240527231908_add_path_to_active_storage_blobs.rb @@ -0,0 +1,5 @@ +class AddPathToActiveStorageBlobs < ActiveRecord::Migration[7.1] + def change + add_column :active_storage_blobs, :filepath, :string, null: false, default: '' + end +end diff --git a/rails-backend/db/migrate/20240606184819_create_tags.rb b/rails-backend/db/migrate/20240606184819_create_tags.rb new file mode 100644 index 0000000..9b33939 --- /dev/null +++ b/rails-backend/db/migrate/20240606184819_create_tags.rb @@ -0,0 +1,10 @@ +class CreateTags < ActiveRecord::Migration[7.1] + def change + create_table :tags do |t| + t.string :tag_type, null: false + t.string :name, null: false + + t.timestamps + end + end +end diff --git a/rails-backend/db/migrate/20240606200659_create_tags_games_join_table.rb b/rails-backend/db/migrate/20240606200659_create_tags_games_join_table.rb new file mode 100644 index 0000000..7a0dae4 --- /dev/null +++ b/rails-backend/db/migrate/20240606200659_create_tags_games_join_table.rb @@ -0,0 +1,8 @@ +class CreateTagsGamesJoinTable < ActiveRecord::Migration[7.1] + def change + create_join_table :tags, :games do |t| + t.index :tag_id + t.index :game_id + end + end +end diff --git a/rails-backend/db/schema.rb b/rails-backend/db/schema.rb new file mode 100644 index 0000000..f4cabcc --- /dev/null +++ b/rails-backend/db/schema.rb @@ -0,0 +1,86 @@ +# 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[7.1].define(version: 2024_06_06_200659) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "active_storage_attachments", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.string "service_name", null: false + t.bigint "byte_size", null: false + t.string "checksum" + t.datetime "created_at", null: false + t.string "filepath", default: "", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "active_storage_variant_records", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + + create_table "games", force: :cascade do |t| + t.string "title" + t.string "titleSlug" + t.string "description" + t.string "github_link" + t.string "img_rendering" + t.integer "status", default: 0 + t.integer "order", default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "user_id", null: false + t.index ["user_id"], name: "index_games_on_user_id" + end + + create_table "games_tags", id: false, force: :cascade do |t| + t.bigint "tag_id", null: false + t.bigint "game_id", null: false + t.index ["game_id"], name: "index_games_tags_on_game_id" + t.index ["tag_id"], name: "index_games_tags_on_tag_id" + end + + create_table "tags", force: :cascade do |t| + t.string "tag_type", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: :cascade do |t| + t.string "user_name" + t.string "identifier" + t.string "access_token_digest" + t.json "user_data" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" + add_foreign_key "games", "users" +end diff --git a/rails-backend/db/seeds.rb b/rails-backend/db/seeds.rb new file mode 100644 index 0000000..50c901e --- /dev/null +++ b/rails-backend/db/seeds.rb @@ -0,0 +1,167 @@ +# This file should ensure the existence of records required to run the application in every environment (production, +# development, test). The code here should be idempotent so that it can be executed at any point in every environment. +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). +# +# Example: +# +# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| +# MovieGenre.find_or_create_by!(name: genre_name) +# end + +markdown_sample = <<~HEREDOC +# Telum vim lactente + +## Petebam Circe hic mactare vitae tandem super + +Lorem markdownum Perseu tetigisse instar. Negat inde calidi sibi, in ora +sanguine; vox excitus pes, in in tibi mella! Portasse morte hic venit, latebras +varios servire libera; hic ad augusta forcipe, *illis* est ubi atque. + +Veri inquit pondere. Precatur ego Amymonen quae vidit lunares caput, nequeo, et. +Occidat in nosset pressa, nomine exercita penitus viae gaudent extemplo. +Mensuraque imitamine primum: sine est suas, quo in, est falso est accingere +ibimus ore renuente. Trahit sua nulla per ut vestigia celerique, gemit manes, +quo suae. + +``` +if (graphic_veronica_traceroute + scanRdram < bittorrent_dtd + + bugWindowsOrientation) { + pitchWord = dllTrackbackRemote; + jquery.batchDot.megabyte(cookie - public, memoryDslamSlashdot(2, + socialPpcEncryption)); +} +cron_analyst = ddr_zettabyte_mips; +var digitize = 1; +var friend_gui = artificial.system(alphaWebsite + domain_ibm( + install_ospf_definition, mca_camelcase, 4), 551649, active_trinitron( + microcomputer_spoofing)); +``` + +Ungues in cannae limumque ingrate; in una voce cubitoque fecit. Non nec, uno +vires laesit perque carpere vultus armenta. Via [praetulit clipei +vestis](http://antro.net/) vidit, sive vestes invitas pro ad per nato nam beati. + +## Nec hauriret stantis + +Illa serpentem fugit inlaesas, cum spoliis vultum arbitrium penates fulmina +caelestia moriens videt insidias. Umidus positi, et ripis feremur sit capit +detur tenens. + +- Provolat cum ecce dextro sed suum pomi +- Voce falsa habuit te +- Modo deponere bracchia pectus + +Deus canor incurva usu dolisque tuentes, leto Liber iniquae requies declivis ad +fontibus tali, flagratque aquaticus. Rupit stimuloque, conscia, nimiumque ait +nomen est Libycas, undas. + +> Humumque spectata et vera, **rugosis causam** iaculo sacra, iunctas rege +> triplices contrahit. Potenti unum cava fama genitor testata summa. Comae sit +> cum, dignissima tauri, formatus promissis *in* quoque [quem +> candidaque](http://sulcomaxima.net/), vitalesque? Pro edere rescindere, premit +> mortisque celeri egredior mare pater, una. Arva tu annos fila valles nocte, +> sero deum densetur **soror siccatque Aeacide** certe undique discordia latent +> et. + +Mihi aureus. Eque tuo, illam diris, virgineas erit externis stabula saetae datis +videat vultus depositae nymphas pedum non peto quem. +HEREDOC + +platform_tags = [ + "web", + "web-desktop", + "web-mobile", + "desktop", + "mobile", + "nintendo 64", + "other" +] +platform_tags.each do |tag| + Tag.find_or_create_by!(name: tag, tag_type: "platform") +end + +game_tags = [ + "unity", + "godot", + "raylib", + "c", + "ruby", + "action", + "tech demo", + "idk something", +] +game_tags.each do |tag| + Tag.find_or_create_by!(name: tag, tag_type: "game") +end + +user = User.find_or_create_by!(user_name: "realtradam", identifier: "11139432") + +data_dir = Rails.root.join('db/lfs') + +games = [ + { + title: 'Almost Pong', + github_link: 'https://github.com/realtradam/almost-pong', + img_rendering: 'crisp-edges', + tags: ["web-desktop"] + }, + { + title: 'Bubbles, Behind', + github_link: 'https://github.com/realtradam/TOJam2023', + img_rendering: 'crisp-edges', + tags: ["web-desktop", "desktop"] + }, + { + title: 'Magnet Run', + github_link: 'https://github.com/realtradam/Magnet-Run-3D', + img_rendering: 'crisp-edges', + tags: ["web-desktop", "desktop"] + }, + { + title: 'Optimal Direction', + github_link: 'https://github.com/realtradam/optimal-direction', + img_rendering: 'crisp-edges', + tags: ["web-desktop", "desktop"] + }, + { + title: 'Winter One', + github_link: '', + img_rendering: 'pixelated', + tags: ["web-desktop", "desktop"] + }, + { + title: 'SpaceCube 64', + github_link: 'https://github.com/realtradam/tojam2024', + img_rendering: 'crisp-edges', + tags: ["nintendo 64", "web-desktop"] + }, + { + title: 'Orc: Arena of Time', + github_link: 'https://github.com/realtradam/orc-arena-of-time', + img_rendering: 'pixelated', + tags: ["web-desktop", "desktop"] + }, +] + +games.each do |game| + next if Game.exists?(title: game[:title], user_id: 1) # first user is always me + tags = game[:tags] + game.delete(:tags) + game[:description] = File.read("#{data_dir}/Games/#{game[:title]}/desc.md") + game_obj = user.games.new(game) + game_obj.save_zip("#{data_dir}/Games/#{game[:title]}/index.zip") + game_obj.card_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/card.png"), filename: 'card.png') + game_obj.char_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/character.png"), filename: 'character.png') + game_obj.title_img.attach(io: File.open("#{data_dir}/Games/#{game[:title]}/title.png"), filename: 'title.png') + game_obj.titleSlug = game[:title].parameterize + game_obj.status = 1 + + tags.each do |tag| + tag_obj = Tag.find_by(tag_type: "platform", name: tag) + if tag_obj + game_obj.tags << tag_obj + end + end + + game_obj.save +end diff --git a/rails-backend/docker-compose.yml b/rails-backend/docker-compose.yml new file mode 100644 index 0000000..67167d4 --- /dev/null +++ b/rails-backend/docker-compose.yml @@ -0,0 +1,19 @@ +# docker-compose.yml +services: + app: + build: . + stdin_open: true + tty: true + platform: linux/amd64 + environment: + - RAILS_ENV=development + ports: + - 3000:3000 + volumes: + - .:/rails + command: ["bin/rails", "server", "-b", "0.0.0.0"] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/healthz"] + interval: 30s + timeout: 10s + retries: 5 diff --git a/rails-backend/lib/tasks/.keep b/rails-backend/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/lib/tasks/.keep diff --git a/rails-backend/log/.keep b/rails-backend/log/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/log/.keep diff --git a/rails-backend/public/robots.txt b/rails-backend/public/robots.txt new file mode 100644 index 0000000..c19f78a --- /dev/null +++ b/rails-backend/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/rails-backend/storage/.keep b/rails-backend/storage/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/storage/.keep diff --git a/rails-backend/test/channels/application_cable/connection_test.rb b/rails-backend/test/channels/application_cable/connection_test.rb new file mode 100644 index 0000000..6340bf9 --- /dev/null +++ b/rails-backend/test/channels/application_cable/connection_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +module ApplicationCable + class ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end + end +end diff --git a/rails-backend/test/controllers/.keep b/rails-backend/test/controllers/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/test/controllers/.keep diff --git a/rails-backend/test/controllers/api/v1/auth_controller_test.rb b/rails-backend/test/controllers/api/v1/auth_controller_test.rb new file mode 100644 index 0000000..3a6d312 --- /dev/null +++ b/rails-backend/test/controllers/api/v1/auth_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Api::V1::AuthControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/controllers/api/v1/games_controller_test.rb b/rails-backend/test/controllers/api/v1/games_controller_test.rb new file mode 100644 index 0000000..0052dbb --- /dev/null +++ b/rails-backend/test/controllers/api/v1/games_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Api::V1::GamesControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/controllers/api/v1/tags_controller_test.rb b/rails-backend/test/controllers/api/v1/tags_controller_test.rb new file mode 100644 index 0000000..642edc6 --- /dev/null +++ b/rails-backend/test/controllers/api/v1/tags_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Api::V1::TagsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/controllers/api/v1/users_controller_test.rb b/rails-backend/test/controllers/api/v1/users_controller_test.rb new file mode 100644 index 0000000..bd2d43b --- /dev/null +++ b/rails-backend/test/controllers/api/v1/users_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Api::V1::UsersControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/controllers/platform_tags_controller_test.rb b/rails-backend/test/controllers/platform_tags_controller_test.rb new file mode 100644 index 0000000..eb6257d --- /dev/null +++ b/rails-backend/test/controllers/platform_tags_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class PlatformTagsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/controllers/tags_controller_test.rb b/rails-backend/test/controllers/tags_controller_test.rb new file mode 100644 index 0000000..bbf5c97 --- /dev/null +++ b/rails-backend/test/controllers/tags_controller_test.rb @@ -0,0 +1,18 @@ +require "test_helper" + +class TagsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get tags_index_url + assert_response :success + end + + test "should get create" do + get tags_create_url + assert_response :success + end + + test "should get destroy" do + get tags_destroy_url + assert_response :success + end +end diff --git a/rails-backend/test/fixtures/files/.keep b/rails-backend/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/test/fixtures/files/.keep diff --git a/rails-backend/test/fixtures/games.yml b/rails-backend/test/fixtures/games.yml new file mode 100644 index 0000000..348ba2f --- /dev/null +++ b/rails-backend/test/fixtures/games.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + titleSlug: MyString + +two: + title: MyString + titleSlug: MyString diff --git a/rails-backend/test/fixtures/tags.yml b/rails-backend/test/fixtures/tags.yml new file mode 100644 index 0000000..5b866c5 --- /dev/null +++ b/rails-backend/test/fixtures/tags.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + type: + name: MyString + +two: + type: + name: MyString diff --git a/rails-backend/test/fixtures/users.yml b/rails-backend/test/fixtures/users.yml new file mode 100644 index 0000000..e4d2e35 --- /dev/null +++ b/rails-backend/test/fixtures/users.yml @@ -0,0 +1,13 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + user_name: MyString + identifier: MyString + access_token_digest: MyString + user_data: + +two: + user_name: MyString + identifier: MyString + access_token_digest: MyString + user_data: diff --git a/rails-backend/test/integration/.keep b/rails-backend/test/integration/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/test/integration/.keep diff --git a/rails-backend/test/mailers/.keep b/rails-backend/test/mailers/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/test/mailers/.keep diff --git a/rails-backend/test/models/.keep b/rails-backend/test/models/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/test/models/.keep diff --git a/rails-backend/test/models/game_test.rb b/rails-backend/test/models/game_test.rb new file mode 100644 index 0000000..6628fae --- /dev/null +++ b/rails-backend/test/models/game_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class GameTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/models/tag_test.rb b/rails-backend/test/models/tag_test.rb new file mode 100644 index 0000000..1846cdb --- /dev/null +++ b/rails-backend/test/models/tag_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class TagTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/models/user_test.rb b/rails-backend/test/models/user_test.rb new file mode 100644 index 0000000..5c07f49 --- /dev/null +++ b/rails-backend/test/models/user_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/rails-backend/test/test_helper.rb b/rails-backend/test/test_helper.rb new file mode 100644 index 0000000..0c22470 --- /dev/null +++ b/rails-backend/test/test_helper.rb @@ -0,0 +1,15 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +module ActiveSupport + class TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # 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 +end diff --git a/rails-backend/tmp/.keep b/rails-backend/tmp/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/tmp/.keep diff --git a/rails-backend/tmp/pids/.keep b/rails-backend/tmp/pids/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/tmp/pids/.keep diff --git a/rails-backend/tmp/storage/.keep b/rails-backend/tmp/storage/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/tmp/storage/.keep diff --git a/rails-backend/vendor/.keep b/rails-backend/vendor/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/rails-backend/vendor/.keep |
