Restart on Rails

This commit is contained in:
Justin Edmund 2020-09-14 18:30:54 -07:00
parent 6dcbe6a7fb
commit f616fe23db
94 changed files with 1644 additions and 2288 deletions

5
.env Normal file
View file

@ -0,0 +1,5 @@
PORT=3000
DATABASE=hensei
DATABASE_USER=justin
DATABASE_PASSWORD=

87
.gitignore vendored
View file

@ -1,67 +1,32 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# 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'
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Ignore bundler config.
/.bundle
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-*
# Coverage directory used by tools like istanbul
coverage
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# nyc test coverage
.nyc_output
# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Ignore uploaded files in development.
/storage/*
!/storage/.keep
.byebug_history
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Cache directory
.cache/
# Dependency directories
node_modules/
jspm_packages/
# Distribution directories
dist/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# DS_Store
.DS_Store
# Ignore master key for decrypting credentials and more.
/config/master.key

1
.ruby-version Normal file
View file

@ -0,0 +1 @@
ruby-2.7.1

97
Gemfile Normal file
View file

@ -0,0 +1,97 @@
source 'https://rubygems.org'
ruby '2.7.1'
gem 'rails', '~> 6.0'
gem 'pg', '~> 1.2.3'
gem 'bootsnap', '~> 1.4.8'
gem 'rack-cors', '1.1.1'
# A Ruby Web Server Built For Concurrency
gem 'puma'
# Process manager for applications with multiple components
gem 'foreman'
# Doorkeeper is an OAuth 2 provider for Rails
gem 'doorkeeper'
# A sophisticated and secure hash algorithm for
# hashing passwords.
gem 'bcrypt'
# Create pretty URLs and work with human-friendly
# strings as if they were numeric ids for ActiveRecord
# models.
gem 'friendly_id'
# Templating system with JSON, XML and Plist support.
gem 'rabl'
# Optimized JSON.
gem 'oj'
# ActiveModel XML serializers
# Required by Draper after Rails 5
gem 'activemodel-serializers-xml'
# URL Validation for Rails.
gem 'validate_url'
gem 'addressable'
# Cloud services
gem 'fog-aws'
gem 'imgix-rails'
# Assorted utilities
gem 'awesome_print'
gem 'html_routes'
gem 'aws-sdk-s3', require: false
# Simple Rails app configuration
gem 'figaro'
# Responder?
gem 'responders'
# Parse emoji to strings
gem 'gemoji-parser'
# Raven is a Ruby client for Sentry
gem "sentry-raven"
# An awesome replacement for acts_as_nested_set and better_nested_set.
gem 'awesome_nested_set'
# An email validator for Rails
gem "email_validator"
gem 'sinatra'
gem 'pg_search'
group :doc do
gem 'sdoc'
gem 'apipie-rails'
end
group :development, :test do
gem 'dotenv-rails'
gem 'factory_bot_rails'
gem 'faker'
gem 'rspec-rails'
gem 'rspec_junit_formatter'
end
group :development do
gem 'listen'
gem 'spring-commands-rspec'
gem 'spring'
end
group :test do
gem 'api_matchers'
gem 'byebug'
gem 'database_cleaner'
gem 'shoulda-matchers'
gem 'simplecov', :require => false
end

351
Gemfile.lock Normal file
View file

@ -0,0 +1,351 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.3)
actionpack (= 6.0.3.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
mail (>= 2.7.1)
actionmailer (6.0.3.3)
actionpack (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.3)
actionview (= 6.0.3.3)
activesupport (= 6.0.3.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.3)
actionpack (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
nokogiri (>= 1.8.5)
actionview (6.0.3.3)
activesupport (= 6.0.3.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.3)
activesupport (= 6.0.3.3)
globalid (>= 0.3.6)
activemodel (6.0.3.3)
activesupport (= 6.0.3.3)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.0.3.3)
activemodel (= 6.0.3.3)
activesupport (= 6.0.3.3)
activestorage (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
marcel (~> 0.3.1)
activesupport (6.0.3.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
api_matchers (0.6.2)
activesupport (>= 3.2.5)
nokogiri (>= 1.5.2)
rspec (>= 3.1)
apipie-rails (0.5.18)
rails (>= 4.1)
awesome_nested_set (3.2.1)
activerecord (>= 4.0.0, < 7.0)
awesome_print (1.8.0)
aws-eventstream (1.1.0)
aws-partitions (1.368.0)
aws-sdk-core (3.105.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.37.0)
aws-sdk-core (~> 3, >= 3.99.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.80.0)
aws-sdk-core (~> 3, >= 3.104.3)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.2)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16)
bootsnap (1.4.8)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.7)
crass (1.0.6)
database_cleaner (1.8.5)
diff-lcs (1.4.4)
docile (1.3.2)
doorkeeper (5.4.0)
railties (>= 5)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
email_validator (2.0.1)
activemodel
erubi (1.9.0)
excon (0.76.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
railties (>= 5.0.0)
faker (2.13.0)
i18n (>= 1.6, < 2)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ffi (1.13.1)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
fog-aws (3.6.7)
fog-core (~> 2.1)
fog-json (~> 1.1)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (2.2.0)
builder
excon (~> 0.71)
formatador (~> 0.2)
mime-types
fog-json (1.2.0)
fog-core
multi_json (~> 1.10)
fog-xml (0.1.3)
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
foreman (0.87.2)
formatador (0.2.5)
friendly_id (5.4.0)
activerecord (>= 4.0.0)
gemoji (3.0.1)
gemoji-parser (1.3.1)
gemoji (>= 2.1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
html_routes (1.1)
launchy (~> 2.0)
syntax (~> 1.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
imgix (3.4.0)
addressable
imgix-rails (4.0.2)
imgix (~> 3.0)
ipaddress (0.8.3)
jmespath (1.4.0)
launchy (2.5.0)
addressable (~> 2.7)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.2)
msgpack (1.3.3)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.3)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oj (3.10.14)
pg (1.2.3)
pg_search (2.3.2)
activerecord (>= 5.2)
activesupport (>= 5.2)
public_suffix (4.0.6)
puma (4.3.6)
nio4r (~> 2.0)
rabl (0.14.3)
activesupport (>= 2.3.14)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-protection (2.1.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.3)
actioncable (= 6.0.3.3)
actionmailbox (= 6.0.3.3)
actionmailer (= 6.0.3.3)
actionpack (= 6.0.3.3)
actiontext (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
activemodel (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
bundler (>= 1.3.0)
railties (= 6.0.3.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.3)
actionpack (= 6.0.3.3)
activesupport (= 6.0.3.3)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.2.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-rails (4.0.1)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
ruby2_keywords (0.0.2)
sdoc (1.1.0)
rdoc (>= 5.0)
sentry-raven (3.0.4)
faraday (>= 1.0)
shoulda-matchers (4.4.1)
activesupport (>= 4.2.0)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spring (2.1.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
syntax (1.2.2)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.7)
thread_safe (~> 0.1)
validate_url (1.0.11)
activemodel (>= 3.0.0)
public_suffix
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.0)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml
addressable
api_matchers
apipie-rails
awesome_nested_set
awesome_print
aws-sdk-s3
bcrypt
bootsnap (~> 1.4.8)
byebug
database_cleaner
doorkeeper
dotenv-rails
email_validator
factory_bot_rails
faker
figaro
fog-aws
foreman
friendly_id
gemoji-parser
html_routes
imgix-rails
listen
oj
pg (~> 1.2.3)
pg_search
puma
rabl
rack-cors (= 1.1.1)
rails (~> 6.0)
responders
rspec-rails
rspec_junit_formatter
sdoc
sentry-raven
shoulda-matchers
simplecov
sinatra
spring
spring-commands-rspec
validate_url
RUBY VERSION
ruby 2.7.1p83
BUNDLED WITH
2.1.4

24
README.md Normal file
View file

@ -0,0 +1,24 @@
# README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...

6
Rakefile Normal file
View file

@ -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

View file

@ -0,0 +1,36 @@
module Api
class ApplicationController < ActionController::API
include Doorkeeper::Rails::Helpers
rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
rescue_from ActiveRecord::RecordNotDestroyed, with: :render_unprocessable_entity_response
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
rescue_from ActiveRecord::RecordNotSaved, with: :render_unprocessable_entity_response
rescue_from ActiveRecord::RecordNotUnique, with: :render_unprocessable_entity_response
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response
before_action :current_user
# Assign the current user if the Doorkeeper token isn't nil
def current_user
@current_user ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
return @current_user
end
### Error response methods
def render_unprocessable_entity_response(exception)
@exception = exception
render action: 'errors', status: :unprocessable_entity
end
def render_not_found_response(exception)
response = { errors: [{ message: "Record could not be found.", code: "not_found" }]}
render 'not_found', status: :not_found
end
def render_unauthorized_response(exception)
render action: 'errors', status: :unauthorized
end
end
end

View file

@ -0,0 +1,17 @@
class Api::V1::PartiesController < ActionController::API
def index
parties = Parties.all
end
def create
end
def show
end
def update
end
def destroy
end
end

View file

@ -0,0 +1,10 @@
class Api::V1::SearchController < ApplicationController
def index
logger.debug params
if params[:query].present?
@weapons = Weapon.search(params[:query])
else
@weapons = Weapon.all
end
end
end

View file

@ -0,0 +1,27 @@
class Api::V1::UsersController < ActionController::API
def create
@user = User.new(user_params)
render :create, status: :created if @user.save!
end
def email_available
@available = User.where("email = ?", params[:email]).count == 0
render :email_available
end
def show
end
def update
end
def destroy
end
private
# Specify whitelisted properties that can be modified.
def user_params
params.require(:user).permit(:username, :email, :password, :password_confirmation, :granblue_id)
end
end

View file

@ -0,0 +1,6 @@
class ApplicationController < ActionController::API
# Not usually required for Rails 5 in API mode, but
# necessary here because we're using RABL.
include ActionView::Rendering
append_view_path "#{Rails.root}/app/views"
end

View file

View file

@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

View file

View file

@ -0,0 +1,2 @@
class GridWeapon < ApplicationRecord
end

2
app/models/parties.rb Normal file
View file

@ -0,0 +1,2 @@
class Party < ApplicationRecord
end

2
app/models/user.rb Normal file
View file

@ -0,0 +1,2 @@
class User < ApplicationRecord
end

11
app/models/weapon.rb Normal file
View file

@ -0,0 +1,11 @@
class Weapon < ApplicationRecord
include PgSearch::Model
pg_search_scope :search,
against: [:name_en, :name_jp],
using: {
tsearch: {
prefix: true
}
}
end

2
app/models/weapon_key.rb Normal file
View file

@ -0,0 +1,2 @@
class WeaponKey < ApplicationRecord
end

View file

View file

@ -0,0 +1,3 @@
collection @weapons, :object_root => false
extends 'weapons/base'

View file

@ -0,0 +1,5 @@
object :user
attributes :id,
:username,
:granblue_id

View file

@ -0,0 +1,9 @@
object false
child(@user) {
attributes :id, :email, :username
} unless @user.blank?
node(:error) {
@error
} unless @error.blank?

View file

@ -0,0 +1,5 @@
object false
node(:available) {
@available
}

View file

@ -0,0 +1,40 @@
object :weapon
attributes :id,
:granblue_id,
:element,
:proficiency,
:max_level,
:max_skill_level
node :name do |w|
{
:en => w.name_en,
:jp => w.name_jp
}
end
node :uncap do |w|
{
:flb => w.flb,
:ulb => w.ulb
}
end
node :hp do |w|
{
:min_hp => w.min_hp,
:max_hp => w.max_hp,
:max_hp_flb => w.max_hp_flb,
:max_hp_ulb => w.max_hp_ulb
}
end
node :atk do |w|
{
:min_atk => w.min_atk,
:max_atk => w.max_atk,
:max_atk_flb => w.max_atk_flb,
:max_atk_ulb => w.max_atk_ulb
}
end

114
bin/bundle Executable file
View file

@ -0,0 +1,114 @@
#!/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 =~ 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", __FILE__)
end
def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
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_version
@bundler_version ||=
env_var_version || cli_arg_version ||
lockfile_version
end
def bundler_requirement
return "#{Gem::Requirement.default}.a" unless bundler_version
bundler_gem_version = Gem::Version.new(bundler_version)
requirement = bundler_gem_version.approximate_recommendation
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
requirement += ".a" if bundler_gem_version.prerelease?
requirement
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

9
bin/rails Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

9
bin/rake Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run

8
bin/rspec Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')

33
bin/setup Executable file
View file

@ -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) || abort("\n== Command #{args} failed ==")
end
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
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

17
bin/spring Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# This file loads Spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require 'rubygems'
require 'bundler'
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
end
end

5
config.ru Normal file
View file

@ -0,0 +1,5 @@
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application

35
config/application.rb Normal file
View file

@ -0,0 +1,35 @@
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module HenseiApi
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
# 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
end
end

4
config/boot.rb Normal file
View file

@ -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.

10
config/cable.yml Normal file
View file

@ -0,0 +1,10 @@
development:
adapter: async
test:
adapter: test
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: hensei_api_production

View file

@ -0,0 +1 @@
d2FydGGNzmcDxx3yD8kWlU7vquTJA/QHjPxZhjcoV65DZYU2JgRZSwL+zzE+Vl4bfXtkHKXhyI821y2DvcCtFpHPmNuUncmvmt+jq9mkrK1KuQts9FLshzw1JdCDioGr+JUmMmb55nPChtHUTnd+eW7BXi9KfBtogA9vDlkEG47epYKv0Wn99ziOP/fyvIPVC+nRtUePHQvDAqIENK7doHDKoDhNkhYbCNwH8Xa+F+kZNVKMgpyoCkNDPg10NyUhub7rHBEX41xGeluZVGAkG6HsBB1XNHAkyCQroBKh/XTHZ4brCTeaoJHL3W+/nwZrRDnBVWl7p6lh17JGgfmTzx/oNBqk/FJHR9lfAdkh/msrqpl5YlnsB9nY6vmjEEX4epylGYWDndoo0INYLawOZp1xFgQFedPb7ZU5--f6jX9dWlDgeyy6gd--nHpeshtZQBL1eBzNeocBoA==

19
config/database.yml Normal file
View file

@ -0,0 +1,19 @@
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: hensei_dev
username: justin
password:
encoding: utf8
test:
<<: *default
database: hensei_test
production:
<<: *default
database: hensei

5
config/environment.rb Normal file
View file

@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View file

@ -0,0 +1,54 @@
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 on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.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
config.action_controller.allow_forgery_protection = false
# 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 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
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

View file

@ -0,0 +1,107 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.allow_forgery_protection = false
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "hensei_api_production"
# config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end

View file

@ -0,0 +1,49 @@
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.cache_classes = false
config.action_view.cache_template_loading = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end

View file

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View file

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View file

@ -0,0 +1,16 @@
# 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 '127.0.0.1:1234'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end

View file

@ -0,0 +1,20 @@
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins)
orm :active_record
# Issue access tokens with refresh token (disabled by default)
use_refresh_token
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
access_token_expires_in 1.month
# This block will be called to authenticate the resource owner.
resource_owner_from_credentials do |routes|
User.find_by(email: params[:username]).try(:authenticate, params[:password])
end
# Specify what grant flows are enabled in array of Strings. The valid
# strings and the flows they enable are:
grant_flows %w(authorization_code client_credentials password)
end

View file

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View file

@ -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

View file

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View file

@ -0,0 +1,3 @@
Rabl.configure do |config|
config.view_paths = [Rails.root.join('app', 'views', 'api', 'v1')]
end

View file

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

33
config/locales/en.yml Normal file
View file

@ -0,0 +1,33 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at https://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

38
config/puma.rb Normal file
View file

@ -0,0 +1,38 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

13
config/routes.rb Normal file
View file

@ -0,0 +1,13 @@
Rails.application.routes.draw do
use_doorkeeper do
skip_controllers :applications, :authorized_applications
end
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :parties, only: [:index]
resources :users, only: [:create, :show]
resources :search, only: [:index]
end
end
end

6
config/spring.rb Normal file
View file

@ -0,0 +1,6 @@
Spring.watch(
".ruby-version",
".rbenv-vars",
"tmp/restart.txt",
"tmp/caching-dev.txt"
)

34
config/storage.yml Normal file
View file

@ -0,0 +1,34 @@
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]

View file

@ -0,0 +1,5 @@
class EnableUuidExtension < ActiveRecord::Migration[5.0]
def change
enable_extension 'uuid-ossp'
end
end

View file

@ -0,0 +1,12 @@
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users, id: :uuid do |t|
t.string :email
t.string :password
t.string :username
t.integer :granblue_id
t.timestamps
end
end
end

View file

@ -0,0 +1,28 @@
class CreateWeapons < ActiveRecord::Migration[6.0]
def change
create_table :weapons, id: :uuid do |t|
t.string :name_en
t.string :name_jp
t.integer :granblue_id
t.integer :rarity
t.integer :element
t.integer :proficiency
t.string :series
t.boolean :flb
t.boolean :ulb
t.integer :max_level
t.integer :max_skill_level
t.integer :min_hp
t.integer :max_hp
t.integer :max_hp_flb
t.integer :max_hp_ulb
t.integer :min_atk
t.integer :max_atk
t.integer :max_atk_flb
t.integer :max_atk_ulb
end
end
end

View file

@ -0,0 +1,15 @@
class CreateParties < ActiveRecord::Migration[6.0]
def change
create_table :parties, id: :uuid do |t|
t.belongs_to :user, type: :uuid
t.string :hash
t.string :characters, array: true, default: []
t.string :weapons, array: true, default: []
t.string :summons, array: true, default: []
t.timestamps
end
end
end

View file

@ -0,0 +1,16 @@
class CreateGridWeapons < ActiveRecord::Migration[6.0]
def change
create_table :grid_weapons do |t|
t.belongs_to :composition, type: :uuid
t.references :weapon, type: :uuid
t.references :weapon_key1, class_name: 'WeaponKey', type: :uuid
t.references :weapon_key2, class_name: 'WeaponKey', type: :uuid
t.integer :uncap_level
t.integer :position
t.timestamps
end
end
end

View file

@ -0,0 +1,13 @@
class CreateWeaponKeys < ActiveRecord::Migration[6.0]
def change
create_table :weapon_keys do |t|
t.string :name_en
t.string :name_jp
t.integer :series
t.integer :type
t.timestamps
end
end
end

88
db/schema.rb Normal file
View file

@ -0,0 +1,88 @@
# 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 `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_09_13_092045) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
enable_extension "uuid-ossp"
create_table "compositions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "user_id"
t.string "hash"
t.string "characters", default: [], array: true
t.string "weapons", default: [], array: true
t.string "summons", default: [], array: true
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id"], name: "index_compositions_on_user_id"
end
create_table "grid_weapons", force: :cascade do |t|
t.uuid "composition_id"
t.uuid "weapon_id"
t.uuid "weapon_key1_id"
t.uuid "weapon_key2_id"
t.integer "uncap_level"
t.integer "position"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["composition_id"], name: "index_grid_weapons_on_composition_id"
t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_id"
t.index ["weapon_key1_id"], name: "index_grid_weapons_on_weapon_key1_id"
t.index ["weapon_key2_id"], name: "index_grid_weapons_on_weapon_key2_id"
end
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "email"
t.string "password"
t.string "username"
t.integer "granblue_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "weapon_keys", force: :cascade do |t|
t.string "name_en"
t.string "name_jp"
t.integer "series"
t.integer "type"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name_en"
t.string "name_jp"
t.integer "granblue_id"
t.integer "rarity"
t.integer "element"
t.integer "proficiency"
t.string "series"
t.boolean "flb"
t.boolean "ulb"
t.integer "max_level"
t.integer "max_skill_level"
t.integer "min_hp"
t.integer "max_hp"
t.integer "max_hp_flb"
t.integer "max_hp_ulb"
t.integer "min_atk"
t.integer "max_atk"
t.integer "max_atk_flb"
t.integer "max_atk_ulb"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
end

7
db/seeds.rb Normal file
View file

@ -0,0 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)

0
lib/tasks/.keep Normal file
View file

0
log/.keep Normal file
View file

2079
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,38 +0,0 @@
{
"name": "hensei-api",
"version": "1.0.0",
"description": "",
"main": "dist/server.js",
"scripts": {
"prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
"build": "tsc",
"prestart": "npm run build",
"start": "nodemon dist/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/cors": "^2.8.7",
"@types/helmet": "0.0.48",
"@types/morgan": "^1.9.1",
"@types/sequelize": "^4.28.9",
"cors": "^2.8.5",
"express": "^4.17.1",
"helmet": "^4.1.1",
"morgan": "^1.10.0",
"pg": "^8.3.3",
"sequelize": "^6.3.5"
},
"devDependencies": {
"@types/express": "^4.17.8",
"@types/node": "^14.10.0",
"@types/pg": "^7.14.4",
"@types/randomstring": "^1.1.6",
"dotenv": "^8.2.0",
"nodemon": "^2.0.4",
"randomstring": "^1.1.5",
"tslint": "^6.1.3",
"typescript": "^4.0.2"
}
}

1
public/robots.txt Normal file
View file

@ -0,0 +1 @@
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file

View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :grid_weapon do
end
end

View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :party do
end
end

5
spec/factories/users.rb Normal file
View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :user do
end
end

View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :weapon_key do
end
end

View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :weapon do
end
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe GridWeapon, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Party, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/user_spec.rb Normal file
View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe User, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe WeaponKey, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Weapon, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -1,75 +0,0 @@
-- Extensions ----------------------------------------------------
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
-- Table Definition ----------------------------------------------
CREATE TABLE IF NOT EXISTS users(
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
username character varying(32) NOT NULL,
granblue_id integer,
email text NOT NULL,
password text NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE parties (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
hash character varying(10),
weapons uuid[],
characters uuid[],
summons uuid[],
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE grid_weapons (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
weapon_id uuid REFERENCES weapons(id),
grid_id uuid,
uncap_level integer,
weapon_key1_id uuid REFERENCES weapon_keys(id),
weapon_key2_id uuid REFERENCES weapon_keys(id),
position integer
);
CREATE TABLE weapons (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
name_en text,
rarity integer,
element integer,
weapon_type integer,
granblue_id integer,
name_jp text,
max_level text,
max_skill_level text,
min_hp text,
max_hp text,
max_hp_flb text,
max_hp_ulb text,
min_atk text,
max_atk text,
max_atk_flb text,
max_atk_ulb text,
weapon_series text,
flb boolean NOT NULL DEFAULT false,
ulb boolean NOT NULL DEFAULT false
);
CREATE TABLE weapon_keys (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
name_en text,
name_jp text,
weapon_key_series integer,
weapon_key_type integer
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX users_pkey ON users(id uuid_ops);
CREATE UNIQUE INDEX parties_pkey ON parties(id uuid_ops);
CREATE UNIQUE INDEX grid_weapons_pkey ON grid_weapons(id uuid_ops);
CREATE UNIQUE INDEX weapons_pkey ON weapons(id uuid_ops);
CREATE UNIQUE INDEX weapon_keys_pkey ON weapon_keys(id uuid_ops);

0
storage/.keep Normal file
View file

View file

@ -0,0 +1,11 @@
require "test_helper"
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
# test "connects with cookies" do
# cookies.signed[:user_id] = 42
#
# connect
#
# assert_equal connection.user_id, "42"
# end
end

0
test/controllers/.keep Normal file
View file

0
test/fixtures/.keep vendored Normal file
View file

0
test/fixtures/files/.keep vendored Normal file
View file

0
test/integration/.keep Normal file
View file

0
test/mailers/.keep Normal file
View file

0
test/models/.keep Normal file
View file

13
test/test_helper.rb Normal file
View file

@ -0,0 +1,13 @@
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
class ActiveSupport::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

0
tmp/.keep Normal file
View file

0
tmp/pids/.keep Normal file
View file

View file

@ -1,21 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*", "data"
]
}

View file

@ -1,14 +0,0 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {
"no-console": false
},
"rules": {
"no-console": false,
"trailing-comma": [false]
},
"rulesDirectory": []
}

0
vendor/.keep vendored Normal file
View file