Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
2696e1f184 | |||
e253a71fc4 | |||
68c64808c5 |
146 changed files with 2027 additions and 3732 deletions
7
.dockerignore
Normal file
7
.dockerignore
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/node_modules
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
|
/.cache
|
||||||
|
/public/build
|
||||||
|
/build
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "next/core-web-vitals"
|
|
||||||
}
|
|
7
.gitattributes
vendored
Normal file
7
.gitattributes
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
|
||||||
|
|
||||||
|
# Mark the database schema as having been generated.
|
||||||
|
db/schema.rb linguist-generated
|
||||||
|
|
||||||
|
# Mark any vendored files as having been vendored.
|
||||||
|
vendor/* linguist-vendored
|
211
.github/workflows/deploy.yml
vendored
Normal file
211
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
name: 🚀 Deploy
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
pull_request: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: ⬣ ESLint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
|
||||||
|
- name: 🔬 Lint
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
typecheck:
|
||||||
|
name: ʦ TypeScript
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
|
||||||
|
- name: 🔎 Type check
|
||||||
|
run: npm run typecheck --if-present
|
||||||
|
|
||||||
|
vitest:
|
||||||
|
name: ⚡ Vitest
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
|
||||||
|
- name: ⚡ Run vitest
|
||||||
|
run: npm run test -- --coverage
|
||||||
|
|
||||||
|
cypress:
|
||||||
|
name: ⚫️ Cypress
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 🏄 Copy test env vars
|
||||||
|
run: cp .env.example .env
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
|
||||||
|
- name: 🐳 Docker compose
|
||||||
|
# the sleep is just there to give time for postgres to get started
|
||||||
|
run: docker-compose up -d && sleep 3
|
||||||
|
env:
|
||||||
|
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"
|
||||||
|
|
||||||
|
- name: 🛠 Setup Database
|
||||||
|
run: npx prisma migrate reset --force
|
||||||
|
|
||||||
|
- name: 🌱 Seed the Database
|
||||||
|
run: npx prisma db seed
|
||||||
|
|
||||||
|
- name: ⚙️ Build
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: 🌳 Cypress run
|
||||||
|
uses: cypress-io/github-action@v3
|
||||||
|
with:
|
||||||
|
start: npm run start:mocks
|
||||||
|
wait-on: "http://localhost:8811"
|
||||||
|
env:
|
||||||
|
PORT: "8811"
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 🐳 Build
|
||||||
|
# only build/deploy main branch on pushes
|
||||||
|
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 👀 Read app name
|
||||||
|
uses: SebRollen/toml-action@v1.0.0
|
||||||
|
id: app_name
|
||||||
|
with:
|
||||||
|
file: "fly.toml"
|
||||||
|
field: "app"
|
||||||
|
|
||||||
|
- name: 🐳 Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
# Setup cache
|
||||||
|
- name: ⚡️ Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: 🔑 Fly Registry Auth
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: registry.fly.io
|
||||||
|
username: x
|
||||||
|
password: ${{ secrets.FLY_API_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🐳 Docker build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
build-args: |
|
||||||
|
COMMIT_SHA=${{ github.sha }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
# This ugly bit is necessary if you don't want your cache to grow forever
|
||||||
|
# till it hits GitHub's limit of 5GB.
|
||||||
|
# Temp fix
|
||||||
|
# https://github.com/docker/build-push-action/issues/252
|
||||||
|
# https://github.com/moby/buildkit/issues/1896
|
||||||
|
- name: 🚚 Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: 🚀 Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint, typecheck, vitest, cypress, build]
|
||||||
|
# only build/deploy main branch on pushes
|
||||||
|
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.9.1
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 👀 Read app name
|
||||||
|
uses: SebRollen/toml-action@v1.0.0
|
||||||
|
id: app_name
|
||||||
|
with:
|
||||||
|
file: "fly.toml"
|
||||||
|
field: "app"
|
||||||
|
|
||||||
|
- name: 🚀 Deploy Staging
|
||||||
|
if: ${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
uses: superfly/flyctl-actions@1.3
|
||||||
|
with:
|
||||||
|
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
|
||||||
|
env:
|
||||||
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🚀 Deploy Production
|
||||||
|
if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
uses: superfly/flyctl-actions@1.3
|
||||||
|
with:
|
||||||
|
args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
|
||||||
|
env:
|
||||||
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
62
.gitignore
vendored
62
.gitignore
vendored
|
@ -1,40 +1,38 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# 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'
|
||||||
|
|
||||||
# dependencies
|
# Ignore bundler config.
|
||||||
/node_modules
|
/.bundle
|
||||||
/.pnp
|
|
||||||
.pnp.js
|
|
||||||
|
|
||||||
# testing
|
# Ignore the default SQLite database.
|
||||||
/coverage
|
/db/*.sqlite3
|
||||||
|
/db/*.sqlite3-*
|
||||||
|
|
||||||
# next.js
|
# Ignore all logfiles and tempfiles.
|
||||||
/.next/
|
/log/*
|
||||||
/out/
|
/tmp/*
|
||||||
|
!/log/.keep
|
||||||
|
!/tmp/.keep
|
||||||
|
|
||||||
# production
|
# Ignore pidfiles, but keep the directory.
|
||||||
/build
|
/tmp/pids/*
|
||||||
|
!/tmp/pids/
|
||||||
|
!/tmp/pids/.keep
|
||||||
|
|
||||||
# misc
|
# Ignore uploaded files in development.
|
||||||
.DS_Store
|
/storage/*
|
||||||
*.pem
|
!/storage/.keep
|
||||||
|
/tmp/storage/*
|
||||||
|
!/tmp/storage/
|
||||||
|
!/tmp/storage/.keep
|
||||||
|
|
||||||
# debug
|
/public/assets
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# local env files
|
# Ignore master key for decrypting credentials and more.
|
||||||
.env*.local
|
/config/master.key
|
||||||
.env
|
|
||||||
|
|
||||||
# vercel
|
postgres-data/
|
||||||
.vercel
|
.env
|
||||||
|
|
||||||
# prisma data
|
|
||||||
/prisma/migrations
|
|
||||||
/prisma/borders.db
|
|
||||||
|
|
||||||
/public/images/*
|
|
||||||
!/public/images/default.png
|
|
11
.prettierignore
Normal file
11
.prettierignore
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
/build
|
||||||
|
/public/build
|
||||||
|
.env
|
||||||
|
|
||||||
|
/cypress/screenshots
|
||||||
|
/cypress/videos
|
||||||
|
/postgres-data
|
||||||
|
|
||||||
|
/app/styles/tailwind.css
|
1
.ruby-version
Normal file
1
.ruby-version
Normal file
|
@ -0,0 +1 @@
|
||||||
|
system
|
80
Gemfile
Normal file
80
Gemfile
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||||
|
|
||||||
|
ruby "3.1.1"
|
||||||
|
|
||||||
|
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
||||||
|
gem "rails", "~> 7.0.2", ">= 7.0.2.3"
|
||||||
|
|
||||||
|
# gem "devise"
|
||||||
|
|
||||||
|
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
|
||||||
|
gem "sprockets-rails"
|
||||||
|
|
||||||
|
# Use sqlite3 as the database for Active Record
|
||||||
|
gem "sqlite3", "~> 1.4"
|
||||||
|
|
||||||
|
# Use the Puma web server [https://github.com/puma/puma]
|
||||||
|
gem "puma", "~> 5.0"
|
||||||
|
|
||||||
|
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
||||||
|
gem "importmap-rails"
|
||||||
|
|
||||||
|
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
||||||
|
gem "turbo-rails"
|
||||||
|
|
||||||
|
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
||||||
|
gem "stimulus-rails"
|
||||||
|
|
||||||
|
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
||||||
|
gem "jbuilder"
|
||||||
|
|
||||||
|
gem "omniauth"
|
||||||
|
gem "omniauth-discord"
|
||||||
|
# gem "omniauth-rails_csrf_protection"
|
||||||
|
|
||||||
|
gem "dotenv-rails"
|
||||||
|
|
||||||
|
# Use Redis adapter to run Action Cable in production
|
||||||
|
# gem "redis", "~> 4.0"
|
||||||
|
|
||||||
|
# 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[ mingw mswin x64_mingw jruby ]
|
||||||
|
|
||||||
|
# Reduces boot times through caching; required in config/boot.rb
|
||||||
|
gem "bootsnap", require: false
|
||||||
|
|
||||||
|
# Use Sass to process CSS
|
||||||
|
# gem "sassc-rails"
|
||||||
|
|
||||||
|
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
||||||
|
# gem "image_processing", "~> 1.2"
|
||||||
|
|
||||||
|
group :development, :test do
|
||||||
|
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||||
|
gem "debug", platforms: %i[ mri mingw x64_mingw ]
|
||||||
|
end
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
# Use console on exceptions pages [https://github.com/rails/web-console]
|
||||||
|
gem "web-console"
|
||||||
|
|
||||||
|
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
||||||
|
# gem "rack-mini-profiler"
|
||||||
|
|
||||||
|
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
||||||
|
# gem "spring"
|
||||||
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
||||||
|
gem "capybara"
|
||||||
|
gem "selenium-webdriver"
|
||||||
|
gem "webdrivers"
|
||||||
|
end
|
268
Gemfile.lock
Normal file
268
Gemfile.lock
Normal file
|
@ -0,0 +1,268 @@
|
||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
actioncable (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
nio4r (~> 2.0)
|
||||||
|
websocket-driver (>= 0.6.1)
|
||||||
|
actionmailbox (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
activejob (= 7.0.2.3)
|
||||||
|
activerecord (= 7.0.2.3)
|
||||||
|
activestorage (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
mail (>= 2.7.1)
|
||||||
|
net-imap
|
||||||
|
net-pop
|
||||||
|
net-smtp
|
||||||
|
actionmailer (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
actionview (= 7.0.2.3)
|
||||||
|
activejob (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
mail (~> 2.5, >= 2.5.4)
|
||||||
|
net-imap
|
||||||
|
net-pop
|
||||||
|
net-smtp
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
actionpack (7.0.2.3)
|
||||||
|
actionview (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
rack (~> 2.0, >= 2.2.0)
|
||||||
|
rack-test (>= 0.6.3)
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||||
|
actiontext (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
activerecord (= 7.0.2.3)
|
||||||
|
activestorage (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
globalid (>= 0.6.0)
|
||||||
|
nokogiri (>= 1.8.5)
|
||||||
|
actionview (7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
builder (~> 3.1)
|
||||||
|
erubi (~> 1.4)
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||||
|
activejob (7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
globalid (>= 0.3.6)
|
||||||
|
activemodel (7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
activerecord (7.0.2.3)
|
||||||
|
activemodel (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
activestorage (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
activejob (= 7.0.2.3)
|
||||||
|
activerecord (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
marcel (~> 1.0)
|
||||||
|
mini_mime (>= 1.1.0)
|
||||||
|
activesupport (7.0.2.3)
|
||||||
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
|
i18n (>= 1.6, < 2)
|
||||||
|
minitest (>= 5.1)
|
||||||
|
tzinfo (~> 2.0)
|
||||||
|
addressable (2.8.0)
|
||||||
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
|
bindex (0.8.1)
|
||||||
|
bootsnap (1.11.1)
|
||||||
|
msgpack (~> 1.2)
|
||||||
|
builder (3.2.4)
|
||||||
|
capybara (3.36.0)
|
||||||
|
addressable
|
||||||
|
matrix
|
||||||
|
mini_mime (>= 0.1.3)
|
||||||
|
nokogiri (~> 1.8)
|
||||||
|
rack (>= 1.6.0)
|
||||||
|
rack-test (>= 0.6.3)
|
||||||
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
|
xpath (~> 3.2)
|
||||||
|
childprocess (4.1.0)
|
||||||
|
concurrent-ruby (1.1.10)
|
||||||
|
crass (1.0.6)
|
||||||
|
debug (1.5.0)
|
||||||
|
irb (>= 1.3.6)
|
||||||
|
reline (>= 0.2.7)
|
||||||
|
digest (3.1.0)
|
||||||
|
dotenv (2.7.6)
|
||||||
|
dotenv-rails (2.7.6)
|
||||||
|
dotenv (= 2.7.6)
|
||||||
|
railties (>= 3.2)
|
||||||
|
erubi (1.10.0)
|
||||||
|
faraday (2.2.0)
|
||||||
|
faraday-net_http (~> 2.0)
|
||||||
|
ruby2_keywords (>= 0.0.4)
|
||||||
|
faraday-net_http (2.0.1)
|
||||||
|
globalid (1.0.0)
|
||||||
|
activesupport (>= 5.0)
|
||||||
|
hashie (5.0.0)
|
||||||
|
i18n (1.10.0)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
importmap-rails (1.0.3)
|
||||||
|
actionpack (>= 6.0.0)
|
||||||
|
railties (>= 6.0.0)
|
||||||
|
io-console (0.5.11)
|
||||||
|
irb (1.4.1)
|
||||||
|
reline (>= 0.3.0)
|
||||||
|
jbuilder (2.11.5)
|
||||||
|
actionview (>= 5.0.0)
|
||||||
|
activesupport (>= 5.0.0)
|
||||||
|
jwt (2.3.0)
|
||||||
|
loofah (2.16.0)
|
||||||
|
crass (~> 1.0.2)
|
||||||
|
nokogiri (>= 1.5.9)
|
||||||
|
mail (2.7.1)
|
||||||
|
mini_mime (>= 0.1.1)
|
||||||
|
marcel (1.0.2)
|
||||||
|
matrix (0.4.2)
|
||||||
|
method_source (1.0.0)
|
||||||
|
mini_mime (1.1.2)
|
||||||
|
minitest (5.15.0)
|
||||||
|
msgpack (1.5.1)
|
||||||
|
multi_json (1.15.0)
|
||||||
|
multi_xml (0.6.0)
|
||||||
|
net-imap (0.2.3)
|
||||||
|
digest
|
||||||
|
net-protocol
|
||||||
|
strscan
|
||||||
|
net-pop (0.1.1)
|
||||||
|
digest
|
||||||
|
net-protocol
|
||||||
|
timeout
|
||||||
|
net-protocol (0.1.3)
|
||||||
|
timeout
|
||||||
|
net-smtp (0.3.1)
|
||||||
|
digest
|
||||||
|
net-protocol
|
||||||
|
timeout
|
||||||
|
nio4r (2.5.8)
|
||||||
|
nokogiri (1.13.3-x86_64-linux)
|
||||||
|
racc (~> 1.4)
|
||||||
|
oauth2 (1.4.9)
|
||||||
|
faraday (>= 0.17.3, < 3.0)
|
||||||
|
jwt (>= 1.0, < 3.0)
|
||||||
|
multi_json (~> 1.3)
|
||||||
|
multi_xml (~> 0.5)
|
||||||
|
rack (>= 1.2, < 3)
|
||||||
|
omniauth (2.0.4)
|
||||||
|
hashie (>= 3.4.6)
|
||||||
|
rack (>= 1.6.2, < 3)
|
||||||
|
rack-protection
|
||||||
|
omniauth-discord (1.0.2)
|
||||||
|
omniauth (~> 2.0.4)
|
||||||
|
omniauth-oauth2
|
||||||
|
omniauth-oauth2 (1.7.2)
|
||||||
|
oauth2 (~> 1.4)
|
||||||
|
omniauth (>= 1.9, < 3)
|
||||||
|
public_suffix (4.0.6)
|
||||||
|
puma (5.6.4)
|
||||||
|
nio4r (~> 2.0)
|
||||||
|
racc (1.6.0)
|
||||||
|
rack (2.2.3)
|
||||||
|
rack-protection (2.2.0)
|
||||||
|
rack
|
||||||
|
rack-test (1.1.0)
|
||||||
|
rack (>= 1.0, < 3)
|
||||||
|
rails (7.0.2.3)
|
||||||
|
actioncable (= 7.0.2.3)
|
||||||
|
actionmailbox (= 7.0.2.3)
|
||||||
|
actionmailer (= 7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
actiontext (= 7.0.2.3)
|
||||||
|
actionview (= 7.0.2.3)
|
||||||
|
activejob (= 7.0.2.3)
|
||||||
|
activemodel (= 7.0.2.3)
|
||||||
|
activerecord (= 7.0.2.3)
|
||||||
|
activestorage (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
bundler (>= 1.15.0)
|
||||||
|
railties (= 7.0.2.3)
|
||||||
|
rails-dom-testing (2.0.3)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
|
nokogiri (>= 1.6)
|
||||||
|
rails-html-sanitizer (1.4.2)
|
||||||
|
loofah (~> 2.3)
|
||||||
|
railties (7.0.2.3)
|
||||||
|
actionpack (= 7.0.2.3)
|
||||||
|
activesupport (= 7.0.2.3)
|
||||||
|
method_source
|
||||||
|
rake (>= 12.2)
|
||||||
|
thor (~> 1.0)
|
||||||
|
zeitwerk (~> 2.5)
|
||||||
|
rake (13.0.6)
|
||||||
|
regexp_parser (2.3.0)
|
||||||
|
reline (0.3.1)
|
||||||
|
io-console (~> 0.5)
|
||||||
|
rexml (3.2.5)
|
||||||
|
ruby2_keywords (0.0.5)
|
||||||
|
rubyzip (2.3.2)
|
||||||
|
selenium-webdriver (4.1.0)
|
||||||
|
childprocess (>= 0.5, < 5.0)
|
||||||
|
rexml (~> 3.2, >= 3.2.5)
|
||||||
|
rubyzip (>= 1.2.2)
|
||||||
|
sprockets (4.0.3)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
rack (> 1, < 3)
|
||||||
|
sprockets-rails (3.4.2)
|
||||||
|
actionpack (>= 5.2)
|
||||||
|
activesupport (>= 5.2)
|
||||||
|
sprockets (>= 3.0.0)
|
||||||
|
sqlite3 (1.4.2)
|
||||||
|
stimulus-rails (1.0.4)
|
||||||
|
railties (>= 6.0.0)
|
||||||
|
strscan (3.0.1)
|
||||||
|
thor (1.2.1)
|
||||||
|
timeout (0.2.0)
|
||||||
|
turbo-rails (1.0.1)
|
||||||
|
actionpack (>= 6.0.0)
|
||||||
|
railties (>= 6.0.0)
|
||||||
|
tzinfo (2.0.4)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
web-console (4.2.0)
|
||||||
|
actionview (>= 6.0.0)
|
||||||
|
activemodel (>= 6.0.0)
|
||||||
|
bindex (>= 0.4.0)
|
||||||
|
railties (>= 6.0.0)
|
||||||
|
webdrivers (5.0.0)
|
||||||
|
nokogiri (~> 1.6)
|
||||||
|
rubyzip (>= 1.3.0)
|
||||||
|
selenium-webdriver (~> 4.0)
|
||||||
|
websocket-driver (0.7.5)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-extensions (0.1.5)
|
||||||
|
xpath (3.2.0)
|
||||||
|
nokogiri (~> 1.8)
|
||||||
|
zeitwerk (2.5.4)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
bootsnap
|
||||||
|
capybara
|
||||||
|
debug
|
||||||
|
dotenv-rails
|
||||||
|
importmap-rails
|
||||||
|
jbuilder
|
||||||
|
omniauth
|
||||||
|
omniauth-discord
|
||||||
|
puma (~> 5.0)
|
||||||
|
rails (~> 7.0.2, >= 7.0.2.3)
|
||||||
|
selenium-webdriver
|
||||||
|
sprockets-rails
|
||||||
|
sqlite3 (~> 1.4)
|
||||||
|
stimulus-rails
|
||||||
|
turbo-rails
|
||||||
|
tzinfo-data
|
||||||
|
web-console
|
||||||
|
webdrivers
|
||||||
|
|
||||||
|
RUBY VERSION
|
||||||
|
ruby 3.1.1p18
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.3.7
|
36
README.md
36
README.md
|
@ -1,34 +1,24 @@
|
||||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
# README
|
||||||
|
|
||||||
## Getting Started
|
This README would normally document whatever steps are necessary to get the
|
||||||
|
application up and running.
|
||||||
|
|
||||||
First, run the development server:
|
Things you may want to cover:
|
||||||
|
|
||||||
```bash
|
* Ruby version
|
||||||
npm run dev
|
|
||||||
# or
|
|
||||||
yarn dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
* System dependencies
|
||||||
|
|
||||||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
* Configuration
|
||||||
|
|
||||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
|
* Database creation
|
||||||
|
|
||||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
* Database initialization
|
||||||
|
|
||||||
## Learn More
|
* How to run the test suite
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
* Services (job queues, cache servers, search engines, etc.)
|
||||||
|
|
||||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
* Deployment instructions
|
||||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
||||||
|
|
||||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
* ...
|
||||||
|
|
||||||
## Deploy on Vercel
|
|
||||||
|
|
||||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
||||||
|
|
||||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
|
||||||
|
|
6
Rakefile
Normal file
6
Rakefile
Normal 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
|
4
app/assets/config/manifest.js
Normal file
4
app/assets/config/manifest.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
//= link_tree ../images
|
||||||
|
//= link_directory ../stylesheets .css
|
||||||
|
//= link_tree ../../javascript .js
|
||||||
|
//= link_tree ../../../vendor/javascript .js
|
0
app/assets/images/.keep
Normal file
0
app/assets/images/.keep
Normal file
15
app/assets/stylesheets/application.css
Normal file
15
app/assets/stylesheets/application.css
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||||
|
* listed below.
|
||||||
|
*
|
||||||
|
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
|
||||||
|
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||||
|
*
|
||||||
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||||
|
* compiled file so the styles you add here take precedence over styles defined in any other CSS
|
||||||
|
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||||
|
* It is generally better to create a new file per style scope.
|
||||||
|
*
|
||||||
|
*= require_tree .
|
||||||
|
*= require_self
|
||||||
|
*/
|
4
app/channels/application_cable/channel.rb
Normal file
4
app/channels/application_cable/channel.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module ApplicationCable
|
||||||
|
class Channel < ActionCable::Channel::Base
|
||||||
|
end
|
||||||
|
end
|
4
app/channels/application_cable/connection.rb
Normal file
4
app/channels/application_cable/connection.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module ApplicationCable
|
||||||
|
class Connection < ActionCable::Connection::Base
|
||||||
|
end
|
||||||
|
end
|
2
app/controllers/application_controller.rb
Normal file
2
app/controllers/application_controller.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class ApplicationController < ActionController::Base
|
||||||
|
end
|
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
2
app/controllers/discord_users_controller.rb
Normal file
2
app/controllers/discord_users_controller.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class DiscordUsersController < ApplicationController
|
||||||
|
end
|
2
app/controllers/sessions_controller.rb
Normal file
2
app/controllers/sessions_controller.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class SessionsController < ApplicationController
|
||||||
|
end
|
70
app/controllers/users_controller.rb
Normal file
70
app/controllers/users_controller.rb
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
class UsersController < ApplicationController
|
||||||
|
before_action :set_user, only: %i[ show edit update destroy ]
|
||||||
|
|
||||||
|
# GET /users or /users.json
|
||||||
|
def index
|
||||||
|
@users = User.all
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/1 or /users/1.json
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/new
|
||||||
|
def new
|
||||||
|
@user = User.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /users/1/edit
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /users or /users.json
|
||||||
|
def create
|
||||||
|
@user = User.new(user_params)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @user.save
|
||||||
|
format.html { redirect_to user_url(@user), notice: "User was successfully created." }
|
||||||
|
format.json { render :show, status: :created, location: @user }
|
||||||
|
else
|
||||||
|
format.html { render :new, status: :unprocessable_entity }
|
||||||
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PATCH/PUT /users/1 or /users/1.json
|
||||||
|
def update
|
||||||
|
respond_to do |format|
|
||||||
|
if @user.update(user_params)
|
||||||
|
format.html { redirect_to user_url(@user), notice: "User was successfully updated." }
|
||||||
|
format.json { render :show, status: :ok, location: @user }
|
||||||
|
else
|
||||||
|
format.html { render :edit, status: :unprocessable_entity }
|
||||||
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /users/1 or /users/1.json
|
||||||
|
def destroy
|
||||||
|
@user.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to users_url, notice: "User was successfully destroyed." }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
def set_user
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Only allow a list of trusted parameters through.
|
||||||
|
def user_params
|
||||||
|
params.require(:user).permit(:provider, :uid, :border)
|
||||||
|
end
|
||||||
|
end
|
2
app/helpers/application_helper.rb
Normal file
2
app/helpers/application_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module ApplicationHelper
|
||||||
|
end
|
2
app/helpers/discord_users_helper.rb
Normal file
2
app/helpers/discord_users_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module DiscordUsersHelper
|
||||||
|
end
|
2
app/helpers/sessions_helper.rb
Normal file
2
app/helpers/sessions_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module SessionsHelper
|
||||||
|
end
|
2
app/helpers/users_helper.rb
Normal file
2
app/helpers/users_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module UsersHelper
|
||||||
|
end
|
3
app/javascript/application.js
Normal file
3
app/javascript/application.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||||
|
import "@hotwired/turbo-rails"
|
||||||
|
import "controllers"
|
9
app/javascript/controllers/application.js
Normal file
9
app/javascript/controllers/application.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { Application } from "@hotwired/stimulus"
|
||||||
|
|
||||||
|
const application = Application.start()
|
||||||
|
|
||||||
|
// Configure Stimulus development experience
|
||||||
|
application.debug = false
|
||||||
|
window.Stimulus = application
|
||||||
|
|
||||||
|
export { application }
|
7
app/javascript/controllers/hello_controller.js
Normal file
7
app/javascript/controllers/hello_controller.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { Controller } from "@hotwired/stimulus"
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
this.element.textContent = "Hello World!"
|
||||||
|
}
|
||||||
|
}
|
11
app/javascript/controllers/index.js
Normal file
11
app/javascript/controllers/index.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Import and register all your controllers from the importmap under controllers/*
|
||||||
|
|
||||||
|
import { application } from "controllers/application"
|
||||||
|
|
||||||
|
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
||||||
|
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||||
|
eagerLoadControllersFrom("controllers", application)
|
||||||
|
|
||||||
|
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
||||||
|
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
||||||
|
// lazyLoadControllersFrom("controllers", application)
|
7
app/jobs/application_job.rb
Normal file
7
app/jobs/application_job.rb
Normal file
|
@ -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
|
4
app/mailers/application_mailer.rb
Normal file
4
app/mailers/application_mailer.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class ApplicationMailer < ActionMailer::Base
|
||||||
|
default from: "from@example.com"
|
||||||
|
layout "mailer"
|
||||||
|
end
|
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
|
primary_abstract_class
|
||||||
|
end
|
0
app/models/concerns/.keep
Normal file
0
app/models/concerns/.keep
Normal file
4
app/models/discord.rb
Normal file
4
app/models/discord.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class DiscordUser < ApplicationRecord
|
||||||
|
attr_accessible :discord_id, :username, :discriminator, :avatar
|
||||||
|
validates :discord_id, :uniqueness => true
|
||||||
|
end
|
2
app/models/user.rb
Normal file
2
app/models/user.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class User < ApplicationRecord
|
||||||
|
end
|
16
app/views/layouts/application.html.erb
Normal file
16
app/views/layouts/application.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Borders</title>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
<%= csp_meta_tag %>
|
||||||
|
|
||||||
|
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||||
|
<%= javascript_importmap_tags %>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%= yield %>
|
||||||
|
</body>
|
||||||
|
</html>
|
13
app/views/layouts/mailer.html.erb
Normal file
13
app/views/layouts/mailer.html.erb
Normal file
|
@ -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>
|
1
app/views/layouts/mailer.text.erb
Normal file
1
app/views/layouts/mailer.text.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= yield %>
|
32
app/views/users/_form.html.erb
Normal file
32
app/views/users/_form.html.erb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<%= form_with(model: user) do |form| %>
|
||||||
|
<% if user.errors.any? %>
|
||||||
|
<div style="color: red">
|
||||||
|
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<% user.errors.each do |error| %>
|
||||||
|
<li><%= error.full_message %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= form.label :provider, style: "display: block" %>
|
||||||
|
<%= form.text_field :provider %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= form.label :uid, style: "display: block" %>
|
||||||
|
<%= form.text_field :uid %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= form.label :border, style: "display: block" %>
|
||||||
|
<%= form.text_field :border %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= form.submit %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
17
app/views/users/_user.html.erb
Normal file
17
app/views/users/_user.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<div id="<%= dom_id user %>">
|
||||||
|
<p>
|
||||||
|
<strong>Provider:</strong>
|
||||||
|
<%= user.provider %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>Uid:</strong>
|
||||||
|
<%= user.uid %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>Border:</strong>
|
||||||
|
<%= user.border %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
2
app/views/users/_user.json.jbuilder
Normal file
2
app/views/users/_user.json.jbuilder
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
json.extract! user, :id, :provider, :uid, :border, :created_at, :updated_at
|
||||||
|
json.url user_url(user, format: :json)
|
10
app/views/users/edit.html.erb
Normal file
10
app/views/users/edit.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<h1>Editing user</h1>
|
||||||
|
|
||||||
|
<%= render "form", user: @user %>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= link_to "Show this user", @user %> |
|
||||||
|
<%= link_to "Back to users", users_path %>
|
||||||
|
</div>
|
14
app/views/users/index.html.erb
Normal file
14
app/views/users/index.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<p style="color: green"><%= notice %></p>
|
||||||
|
|
||||||
|
<h1>Users</h1>
|
||||||
|
|
||||||
|
<div id="users">
|
||||||
|
<% @users.each do |user| %>
|
||||||
|
<%= render user %>
|
||||||
|
<p>
|
||||||
|
<%= link_to "Show this user", user %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= link_to "New user", new_user_path %>
|
1
app/views/users/index.json.jbuilder
Normal file
1
app/views/users/index.json.jbuilder
Normal file
|
@ -0,0 +1 @@
|
||||||
|
json.array! @users, partial: "users/user", as: :user
|
9
app/views/users/new.html.erb
Normal file
9
app/views/users/new.html.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<h1>New user</h1>
|
||||||
|
|
||||||
|
<%= render "form", user: @user %>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= link_to "Back to users", users_path %>
|
||||||
|
</div>
|
10
app/views/users/show.html.erb
Normal file
10
app/views/users/show.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<p style="color: green"><%= notice %></p>
|
||||||
|
|
||||||
|
<%= render @user %>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= link_to "Edit this user", edit_user_path(@user) %> |
|
||||||
|
<%= link_to "Back to users", users_path %>
|
||||||
|
|
||||||
|
<%= button_to "Destroy this user", @user, method: :delete %>
|
||||||
|
</div>
|
1
app/views/users/show.json.jbuilder
Normal file
1
app/views/users/show.json.jbuilder
Normal file
|
@ -0,0 +1 @@
|
||||||
|
json.partial! "users/user", user: @user
|
114
bin/bundle
Executable file
114
bin/bundle
Executable 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_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)
|
||||||
|
|
||||||
|
requirement = bundler_gem_version.approximate_recommendation
|
||||||
|
|
||||||
|
return requirement unless Gem.rubygems_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
|
4
bin/importmap
Executable file
4
bin/importmap
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require_relative "../config/application"
|
||||||
|
require "importmap/commands"
|
4
bin/rails
Executable file
4
bin/rails
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
APP_PATH = File.expand_path("../config/application", __dir__)
|
||||||
|
require_relative "../config/boot"
|
||||||
|
require "rails/commands"
|
4
bin/rake
Executable file
4
bin/rake
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
require_relative "../config/boot"
|
||||||
|
require "rake"
|
||||||
|
Rake.application.run
|
33
bin/setup
Executable file
33
bin/setup
Executable 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 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
|
|
@ -1,129 +0,0 @@
|
||||||
import { useState, useEffect, useRef } from "react";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import PropTypes from "prop-types";
|
|
||||||
|
|
||||||
import { alertService, AlertType } from "../services";
|
|
||||||
|
|
||||||
export { Alert };
|
|
||||||
|
|
||||||
Alert.propTypes = {
|
|
||||||
id: PropTypes.string,
|
|
||||||
fade: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
Alert.defaultProps = {
|
|
||||||
id: "default-alert",
|
|
||||||
fade: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
function Alert({ id, fade }) {
|
|
||||||
const mounted = useRef(false);
|
|
||||||
const router = useRouter();
|
|
||||||
const [alerts, setAlerts] = useState([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
mounted.current = true;
|
|
||||||
|
|
||||||
// subscribe to new alert notifications
|
|
||||||
const subscription = alertService.onAlert(id).subscribe((alert) => {
|
|
||||||
// clear alerts when an empty alert is received
|
|
||||||
if (!alert.message) {
|
|
||||||
setAlerts((alerts) => {
|
|
||||||
// filter out alerts without 'keepAfterRouteChange' flag
|
|
||||||
const filteredAlerts = alerts.filter((x) => x.keepAfterRouteChange);
|
|
||||||
|
|
||||||
// remove 'keepAfterRouteChange' flag on the rest
|
|
||||||
return omit(filteredAlerts, "keepAfterRouteChange");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// add alert to array with unique id
|
|
||||||
alert.itemId = Math.random();
|
|
||||||
setAlerts((alerts) => [...alerts, alert]);
|
|
||||||
|
|
||||||
// auto close alert if required
|
|
||||||
if (alert.autoClose) {
|
|
||||||
setTimeout(() => removeAlert(alert), 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// clear alerts on location change
|
|
||||||
const clearAlerts = () => alertService.clear(id);
|
|
||||||
router.events.on("routeChangeStart", clearAlerts);
|
|
||||||
|
|
||||||
// clean up function that runs when the component unmounts
|
|
||||||
return () => {
|
|
||||||
mounted.current = false;
|
|
||||||
|
|
||||||
// unsubscribe to avoid memory leaks
|
|
||||||
subscription.unsubscribe();
|
|
||||||
router.events.off("routeChangeStart", clearAlerts);
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
function omit(arr, key) {
|
|
||||||
return arr.map((obj) => {
|
|
||||||
const { [key]: omitted, ...rest } = obj;
|
|
||||||
return rest;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeAlert(alert) {
|
|
||||||
if (!mounted.current) return;
|
|
||||||
|
|
||||||
if (fade) {
|
|
||||||
// fade out alert
|
|
||||||
setAlerts((alerts) =>
|
|
||||||
alerts.map((x) =>
|
|
||||||
x.itemId === alert.itemId ? { ...x, fade: true } : x
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// remove alert after faded out
|
|
||||||
setTimeout(() => {
|
|
||||||
setAlerts((alerts) => alerts.filter((x) => x.itemId !== alert.itemId));
|
|
||||||
}, 250);
|
|
||||||
} else {
|
|
||||||
// remove alert
|
|
||||||
setAlerts((alerts) => alerts.filter((x) => x.itemId !== alert.itemId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cssClasses(alert) {
|
|
||||||
if (!alert) return;
|
|
||||||
|
|
||||||
const classes = ["alert", "alert-dismissable"];
|
|
||||||
|
|
||||||
const alertTypeClass = {
|
|
||||||
[AlertType.Success]: "alert-success",
|
|
||||||
[AlertType.Error]: "alert-danger",
|
|
||||||
[AlertType.Info]: "alert-info",
|
|
||||||
[AlertType.Warning]: "alert-warning",
|
|
||||||
};
|
|
||||||
|
|
||||||
classes.push(alertTypeClass[alert.type]);
|
|
||||||
|
|
||||||
if (alert.fade) {
|
|
||||||
classes.push("fade");
|
|
||||||
}
|
|
||||||
|
|
||||||
return classes.join(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!alerts.length) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{alerts.map((alert, index) => (
|
|
||||||
<div key={index} className={cssClasses(alert)}>
|
|
||||||
<a className="close" onClick={() => removeAlert(alert)}>
|
|
||||||
×
|
|
||||||
</a>
|
|
||||||
<span>{alert.message}</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
import Image from "next/image";
|
|
||||||
import styles from "../styles/Components.module.css";
|
|
||||||
|
|
||||||
export default function BorderImage(props) {
|
|
||||||
const { key, border, selected, size, onSelect, customImage } = props;
|
|
||||||
|
|
||||||
const imageSize = size || 128;
|
|
||||||
|
|
||||||
const classNames = [
|
|
||||||
styles.borderKeeper,
|
|
||||||
selected == border.id ? styles.selected : undefined,
|
|
||||||
].join(" ");
|
|
||||||
return (
|
|
||||||
<div className={classNames} key={key}>
|
|
||||||
<Image
|
|
||||||
className={styles.userImage}
|
|
||||||
src={customImage || "/user.png"}
|
|
||||||
alt="user image"
|
|
||||||
width={imageSize}
|
|
||||||
height={imageSize}
|
|
||||||
onClick={(ev) => {
|
|
||||||
onSelect && onSelect(border.id);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Image
|
|
||||||
className={styles.borderImage}
|
|
||||||
src={`/images/${border.imageName}`}
|
|
||||||
alt={`border with id ${border.id}`}
|
|
||||||
width={Math.floor(imageSize * 1.03125)}
|
|
||||||
height={Math.floor(imageSize * 1.03125)}
|
|
||||||
onClick={(ev) => {
|
|
||||||
onSelect && onSelect(border.id);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import BorderImage from "./borderImage";
|
|
||||||
import styles from "../styles/Components.module.css";
|
|
||||||
import { useSession } from "next-auth/react";
|
|
||||||
|
|
||||||
export default function Preview(props) {
|
|
||||||
const { data: session } = useSession();
|
|
||||||
const { data, current, selected, apply } = props;
|
|
||||||
|
|
||||||
const currentItem = data?.filter(
|
|
||||||
(item) => parseInt(item.id) === (current != null ? parseInt(current) : 0)
|
|
||||||
)?.[0];
|
|
||||||
|
|
||||||
const selectedItem = data?.filter(
|
|
||||||
(item) => parseInt(item.id) === parseInt(selected)
|
|
||||||
)?.[0];
|
|
||||||
|
|
||||||
// console.log(currentItem, selectedItem, session);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.preview}>
|
|
||||||
current
|
|
||||||
<br />
|
|
||||||
{currentItem && (
|
|
||||||
<BorderImage
|
|
||||||
border={currentItem}
|
|
||||||
selected={-1}
|
|
||||||
size={256}
|
|
||||||
customImage={session?.user?.image}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<br />
|
|
||||||
new
|
|
||||||
<br />
|
|
||||||
{selectedItem && (
|
|
||||||
<BorderImage
|
|
||||||
border={selectedItem}
|
|
||||||
selected={-1}
|
|
||||||
size={256}
|
|
||||||
customImage={session?.user?.image}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<br />
|
|
||||||
<button onClick={apply}>Apply</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
import BorderImage from "./borderImage";
|
|
||||||
import InfiniteScroll from "react-infinite-scroll-component";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import styles from "../styles/Components.module.css";
|
|
||||||
|
|
||||||
const pageSize = 48;
|
|
||||||
|
|
||||||
export default function Select(props) {
|
|
||||||
const { data, total, onSelect, selected = {} } = props;
|
|
||||||
// console.log("data", data, "selected", selected, total);
|
|
||||||
|
|
||||||
const [scrollIndex, setScrollIndex] = useState(36);
|
|
||||||
const [scrollData, setScrollData] = useState([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setScrollData(data.slice(0, pageSize - 1));
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
const fetchMore = () => {
|
|
||||||
let newData = data.slice(scrollIndex, scrollIndex + pageSize);
|
|
||||||
setScrollData([...scrollData, ...newData]);
|
|
||||||
setScrollIndex(scrollIndex + pageSize);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<InfiniteScroll
|
|
||||||
dataLength={scrollData?.length || 0}
|
|
||||||
next={fetchMore}
|
|
||||||
hasMore={total > scrollData?.length || 0}
|
|
||||||
height={"75vh"}
|
|
||||||
className={styles.select}
|
|
||||||
loader={<h4>Loading...</h4>}
|
|
||||||
endMessage={<h4>No more borders.</h4>}>
|
|
||||||
{scrollData &&
|
|
||||||
scrollData.map((border, index) => {
|
|
||||||
return (
|
|
||||||
<BorderImage
|
|
||||||
key={border.id}
|
|
||||||
border={border}
|
|
||||||
selected={selected}
|
|
||||||
onSelect={onSelect}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</InfiniteScroll>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
import { useSession, signIn, signOut } from "next-auth/react";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import styles from "../styles/Components.module.css";
|
|
||||||
|
|
||||||
export default function UserInfo(props) {
|
|
||||||
const { data: session } = useSession();
|
|
||||||
const { borderData } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<p className={styles.description}>
|
|
||||||
{session
|
|
||||||
? `Signed in as ${session.user.name} (${borderData?.discordId})`
|
|
||||||
: "Not signed in"}
|
|
||||||
<br />
|
|
||||||
{session ? (
|
|
||||||
<button onClick={() => signOut()}>Sign Out</button>
|
|
||||||
) : (
|
|
||||||
<button onClick={() => signIn()}>Sign In</button>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
6
config.ru
Normal file
6
config.ru
Normal file
|
@ -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
|
36
config/application.rb
Normal file
36
config/application.rb
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
require_relative "boot"
|
||||||
|
|
||||||
|
require "rails/all"
|
||||||
|
|
||||||
|
# Require the gems listed in Gemfile, including any gems
|
||||||
|
# you've limited to :test, :development, or :production.
|
||||||
|
Bundler.require(*Rails.groups)
|
||||||
|
|
||||||
|
Dotenv::Railtie.load
|
||||||
|
|
||||||
|
module Borders
|
||||||
|
class Application < Rails::Application
|
||||||
|
# Initialize configuration defaults for originally generated Rails version.
|
||||||
|
config.load_defaults 7.0
|
||||||
|
|
||||||
|
config.hosts << "dev.j4.pm"
|
||||||
|
|
||||||
|
# Configuration for the application, engines, and railties goes here.
|
||||||
|
#
|
||||||
|
# These settings can be overridden in specific environments using the files
|
||||||
|
# in config/environments, which are processed later.
|
||||||
|
#
|
||||||
|
# config.time_zone = "Central Time (US & Canada)"
|
||||||
|
# config.eager_load_paths << Rails.root.join("extras")
|
||||||
|
|
||||||
|
config.session_store :cookie_store, key: '_interslice_session'
|
||||||
|
config.middleware.use ActionDispatch::Cookies
|
||||||
|
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
|
||||||
|
|
||||||
|
config.middleware.use OmniAuth::Builder do
|
||||||
|
provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_SECRET'], scope: 'identify'
|
||||||
|
end
|
||||||
|
|
||||||
|
OmniAuth.config.logger = Rails.logger
|
||||||
|
end
|
||||||
|
end
|
4
config/boot.rb
Normal file
4
config/boot.rb
Normal 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
10
config/cable.yml
Normal 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: borders_production
|
1
config/credentials.yml.enc
Normal file
1
config/credentials.yml.enc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ZtWeNs0IpngwoBiDB0tKSzf4Yzcn2vdeq3ZF6oqiGFxk2mKOZhGbKz1UpS5p4jz1dAPuY9O9AAxCaW5FMFoF8Kt3XRVW3z+krmVrHmQRtMnRSc4CrqrP/W55R49gRcjthuVDQIlu05vo/Q1pVIMWjYTFeVbWNmyYM+Yfr2RS3pStLOqqW5jF8pczXnMj10Tuk7430kiNU+0mJKb8dDO2ONsygfpOJnyGDOri9IyMHtkuHqMYYoDrAhH7UQDD+Y1J4J9QA1LFmqiFksas9lA3sftYejBluKr8VoQBCFWiCrUaTtwOJPDPnkMn/ruiW/P/B98sQKvxFU2dZqtKn9Q1aYu02uV+ZcfTp9bfQN94F4U9KTfYFzUjanRv/pKIJO6MNU+70fguipnED47KL+v20Xu6l0/xlt+5QBjk--FW0lnsnDid5zpyui--hZ6fbB+07IFgNCd1el7bFg==
|
25
config/database.yml
Normal file
25
config/database.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# SQLite. Versions 3.8.0 and up are supported.
|
||||||
|
# gem install sqlite3
|
||||||
|
#
|
||||||
|
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||||
|
# gem "sqlite3"
|
||||||
|
#
|
||||||
|
default: &default
|
||||||
|
adapter: sqlite3
|
||||||
|
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
development:
|
||||||
|
<<: *default
|
||||||
|
database: db/development.sqlite3
|
||||||
|
|
||||||
|
# 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: db/test.sqlite3
|
||||||
|
|
||||||
|
production:
|
||||||
|
<<: *default
|
||||||
|
database: db/production.sqlite3
|
5
config/environment.rb
Normal file
5
config/environment.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Load the Rails application.
|
||||||
|
require_relative "application"
|
||||||
|
|
||||||
|
# Initialize the Rails application.
|
||||||
|
Rails.application.initialize!
|
70
config/environments/development.rb
Normal file
70
config/environments/development.rb
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
require "active_support/core_ext/integer/time"
|
||||||
|
|
||||||
|
Rails.application.configure do
|
||||||
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
|
# In the development environment your application's code is reloaded any time
|
||||||
|
# it changes. This slows down response time but is perfect for development
|
||||||
|
# since you don't have to restart the web server when you make code changes.
|
||||||
|
config.cache_classes = false
|
||||||
|
|
||||||
|
# Do not eager load code on boot.
|
||||||
|
config.eager_load = false
|
||||||
|
|
||||||
|
# Show full error reports.
|
||||||
|
config.consider_all_requests_local = true
|
||||||
|
|
||||||
|
# Enable 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.action_controller.perform_caching = true
|
||||||
|
config.action_controller.enable_fragment_cache_logging = true
|
||||||
|
|
||||||
|
config.cache_store = :memory_store
|
||||||
|
config.public_file_server.headers = {
|
||||||
|
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
config.action_controller.perform_caching = false
|
||||||
|
|
||||||
|
config.cache_store = :null_store
|
||||||
|
end
|
||||||
|
|
||||||
|
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||||
|
config.active_storage.service = :local
|
||||||
|
|
||||||
|
# Don't care if the mailer can't send.
|
||||||
|
config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
||||||
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
|
# Print deprecation notices to the Rails logger.
|
||||||
|
config.active_support.deprecation = :log
|
||||||
|
|
||||||
|
# Raise exceptions for disallowed deprecations.
|
||||||
|
config.active_support.disallowed_deprecation = :raise
|
||||||
|
|
||||||
|
# Tell Active Support which deprecation messages to disallow.
|
||||||
|
config.active_support.disallowed_deprecation_warnings = []
|
||||||
|
|
||||||
|
# Raise an error on page load if there are pending migrations.
|
||||||
|
config.active_record.migration_error = :page_load
|
||||||
|
|
||||||
|
# Highlight code that triggered database queries in logs.
|
||||||
|
config.active_record.verbose_query_logs = true
|
||||||
|
|
||||||
|
# Suppress logger output for asset requests.
|
||||||
|
config.assets.quiet = true
|
||||||
|
|
||||||
|
# Raises error for missing translations.
|
||||||
|
# config.i18n.raise_on_missing_translations = true
|
||||||
|
|
||||||
|
# Annotate rendered view with file names.
|
||||||
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
|
||||||
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||||
|
# config.action_cable.disable_request_forgery_protection = true
|
||||||
|
end
|
93
config/environments/production.rb
Normal file
93
config/environments/production.rb
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
require "active_support/core_ext/integer/time"
|
||||||
|
|
||||||
|
Rails.application.configure do
|
||||||
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
|
# Code is not reloaded between requests.
|
||||||
|
config.cache_classes = true
|
||||||
|
|
||||||
|
# Eager load code on boot. This eager loads most of Rails and
|
||||||
|
# your application in memory, allowing both threaded web servers
|
||||||
|
# and those relying on copy on write to perform better.
|
||||||
|
# Rake tasks automatically ignore this option for performance.
|
||||||
|
config.eager_load = true
|
||||||
|
|
||||||
|
# Full error reports are disabled and caching is turned on.
|
||||||
|
config.consider_all_requests_local = false
|
||||||
|
config.action_controller.perform_caching = true
|
||||||
|
|
||||||
|
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
||||||
|
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
||||||
|
# config.require_master_key = true
|
||||||
|
|
||||||
|
# Disable serving static files from the `/public` folder by default since
|
||||||
|
# Apache or NGINX already handles this.
|
||||||
|
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
||||||
|
|
||||||
|
# Compress CSS using a preprocessor.
|
||||||
|
# config.assets.css_compressor = :sass
|
||||||
|
|
||||||
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||||
|
config.assets.compile = false
|
||||||
|
|
||||||
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||||
|
# config.asset_host = "http://assets.example.com"
|
||||||
|
|
||||||
|
# Specifies the header that your server uses for sending files.
|
||||||
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
||||||
|
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
||||||
|
|
||||||
|
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||||
|
config.active_storage.service = :local
|
||||||
|
|
||||||
|
# Mount Action Cable outside main process or domain.
|
||||||
|
# config.action_cable.mount_path = nil
|
||||||
|
# config.action_cable.url = "wss://example.com/cable"
|
||||||
|
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
||||||
|
|
||||||
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
|
# config.force_ssl = true
|
||||||
|
|
||||||
|
# Include generic and useful information about system operation, but avoid logging too much
|
||||||
|
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
||||||
|
config.log_level = :info
|
||||||
|
|
||||||
|
# Prepend all log lines with the following tags.
|
||||||
|
config.log_tags = [ :request_id ]
|
||||||
|
|
||||||
|
# Use a different cache store in production.
|
||||||
|
# config.cache_store = :mem_cache_store
|
||||||
|
|
||||||
|
# Use a real queuing backend for Active Job (and separate queues per environment).
|
||||||
|
# config.active_job.queue_adapter = :resque
|
||||||
|
# config.active_job.queue_name_prefix = "borders_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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
end
|
60
config/environments/test.rb
Normal file
60
config/environments/test.rb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
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.
|
||||||
|
|
||||||
|
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
||||||
|
config.cache_classes = true
|
||||||
|
|
||||||
|
# Eager loading loads your whole application. When running a single test locally,
|
||||||
|
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
||||||
|
# system, or in some way 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
|
||||||
|
|
||||||
|
# Raise exceptions instead of rendering exception templates.
|
||||||
|
config.action_dispatch.show_exceptions = false
|
||||||
|
|
||||||
|
# Disable request forgery protection in test environment.
|
||||||
|
config.action_controller.allow_forgery_protection = false
|
||||||
|
|
||||||
|
# Store uploaded files on the local file system in a temporary directory.
|
||||||
|
config.active_storage.service = :test
|
||||||
|
|
||||||
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
|
# Tell Action Mailer not to deliver emails to the real world.
|
||||||
|
# The :test delivery method accumulates sent emails in the
|
||||||
|
# ActionMailer::Base.deliveries array.
|
||||||
|
config.action_mailer.delivery_method = :test
|
||||||
|
|
||||||
|
# Print deprecation notices to the stderr.
|
||||||
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
|
# Raise exceptions for disallowed deprecations.
|
||||||
|
config.active_support.disallowed_deprecation = :raise
|
||||||
|
|
||||||
|
# Tell Active Support which deprecation messages to disallow.
|
||||||
|
config.active_support.disallowed_deprecation_warnings = []
|
||||||
|
|
||||||
|
# Raises error for missing translations.
|
||||||
|
# config.i18n.raise_on_missing_translations = true
|
||||||
|
|
||||||
|
# Annotate rendered view with file names.
|
||||||
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
end
|
7
config/importmap.rb
Normal file
7
config/importmap.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Pin npm packages by running ./bin/importmap
|
||||||
|
|
||||||
|
pin "application", preload: true
|
||||||
|
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
|
||||||
|
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
||||||
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
||||||
|
pin_all_from "app/javascript/controllers", under: "controllers"
|
12
config/initializers/assets.rb
Normal file
12
config/initializers/assets.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Version of your assets, change this if you want to expire all your assets.
|
||||||
|
Rails.application.config.assets.version = "1.0"
|
||||||
|
|
||||||
|
# Add additional assets to the asset load path.
|
||||||
|
# Rails.application.config.assets.paths << Emoji.images_path
|
||||||
|
|
||||||
|
# Precompile additional assets.
|
||||||
|
# application.js, application.css, and all non-JS/CSS in the app/assets
|
||||||
|
# folder are already added.
|
||||||
|
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
26
config/initializers/content_security_policy.rb
Normal file
26
config/initializers/content_security_policy.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Define an application-wide content security policy
|
||||||
|
# For further information see the following documentation
|
||||||
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
||||||
|
|
||||||
|
# Rails.application.configure do
|
||||||
|
# config.content_security_policy do |policy|
|
||||||
|
# policy.default_src :self, :https
|
||||||
|
# policy.font_src :self, :https, :data
|
||||||
|
# policy.img_src :self, :https, :data
|
||||||
|
# policy.object_src :none
|
||||||
|
# policy.script_src :self, :https
|
||||||
|
# policy.style_src :self, :https
|
||||||
|
# # Specify URI for violation reports
|
||||||
|
# # policy.report_uri "/csp-violation-report-endpoint"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# # Generate session nonces for permitted importmap and inline scripts
|
||||||
|
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
||||||
|
# config.content_security_policy_nonce_directives = %w(script-src)
|
||||||
|
#
|
||||||
|
# # Report CSP violations to a specified URI. See:
|
||||||
|
# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
||||||
|
# # config.content_security_policy_report_only = true
|
||||||
|
# end
|
8
config/initializers/filter_parameter_logging.rb
Normal file
8
config/initializers/filter_parameter_logging.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Configure parameters to be 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
|
||||||
|
]
|
16
config/initializers/inflections.rb
Normal file
16
config/initializers/inflections.rb
Normal 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
|
11
config/initializers/permissions_policy.rb
Normal file
11
config/initializers/permissions_policy.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Define an application-wide HTTP permissions policy. For further
|
||||||
|
# information see https://developers.google.com/web/updates/2018/06/feature-policy
|
||||||
|
#
|
||||||
|
# Rails.application.config.permissions_policy do |f|
|
||||||
|
# f.camera :none
|
||||||
|
# f.gyroscope :none
|
||||||
|
# f.microphone :none
|
||||||
|
# f.usb :none
|
||||||
|
# f.fullscreen :self
|
||||||
|
# f.payment :self, "https://secure.example.com"
|
||||||
|
# end
|
33
config/locales/en.yml
Normal file
33
config/locales/en.yml
Normal 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"
|
43
config/puma.rb
Normal file
43
config/puma.rb
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Puma can serve each request in a thread from an internal thread pool.
|
||||||
|
# The `threads` method setting takes two numbers: a minimum and maximum.
|
||||||
|
# Any libraries that use thread pools should be configured to match
|
||||||
|
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||||
|
# and maximum; this matches the default thread size of Active Record.
|
||||||
|
#
|
||||||
|
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
||||||
|
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
||||||
|
threads min_threads_count, max_threads_count
|
||||||
|
|
||||||
|
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
||||||
|
# terminating a worker in development environments.
|
||||||
|
#
|
||||||
|
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
||||||
|
|
||||||
|
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
||||||
|
#
|
||||||
|
port ENV.fetch("PORT") { 3000 }
|
||||||
|
|
||||||
|
# Specifies the `environment` that Puma will run in.
|
||||||
|
#
|
||||||
|
environment ENV.fetch("RAILS_ENV") { "development" }
|
||||||
|
|
||||||
|
# Specifies the `pidfile` that Puma will use.
|
||||||
|
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
||||||
|
|
||||||
|
# Specifies the number of `workers` to boot in clustered mode.
|
||||||
|
# Workers are forked web server processes. If using threads and workers together
|
||||||
|
# the concurrency of the application would be max `threads` * `workers`.
|
||||||
|
# Workers do not work on JRuby or Windows (both of which do not support
|
||||||
|
# processes).
|
||||||
|
#
|
||||||
|
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
||||||
|
|
||||||
|
# Use the `preload_app!` method when specifying a `workers` number.
|
||||||
|
# This directive tells Puma to first boot the application and load code
|
||||||
|
# before forking the application. This takes advantage of Copy On Write
|
||||||
|
# process behavior so workers use less memory.
|
||||||
|
#
|
||||||
|
# preload_app!
|
||||||
|
|
||||||
|
# Allow puma to be restarted by `bin/rails restart` command.
|
||||||
|
plugin :tmp_restart
|
12
config/routes.rb
Normal file
12
config/routes.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Rails.application.routes.draw do
|
||||||
|
resources :users
|
||||||
|
resources :discord_users
|
||||||
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||||
|
|
||||||
|
# Defines the root path route ("/")
|
||||||
|
# root "articles#index"
|
||||||
|
match "/login" => "sessions#new", :as => :login, via: [:get, :post]
|
||||||
|
match "/auth/:provider/callback" => "sessions#create", via: [:post]
|
||||||
|
match "/logout" => "sessions#destroy", :as => :logout, via: [:post]
|
||||||
|
match "/auth/failure" => "sessions#failure", via: [:get]
|
||||||
|
end
|
34
config/storage.yml
Normal file
34
config/storage.yml
Normal file
|
@ -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 ]
|
12
db/migrate/20220409220708_create_discordusers.rb
Normal file
12
db/migrate/20220409220708_create_discordusers.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateDiscordusers < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table :discord_users do |t|
|
||||||
|
t.string :discord_id
|
||||||
|
t.string :username
|
||||||
|
t.string :discriminator
|
||||||
|
t.string :avatar
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/20220410011426_create_users.rb
Normal file
11
db/migrate/20220410011426_create_users.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateUsers < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
create_table :users do |t|
|
||||||
|
t.string :provider
|
||||||
|
t.string :uid
|
||||||
|
t.string :border
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
30
db/schema.rb
generated
Normal file
30
db/schema.rb
generated
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# 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.0].define(version: 2022_04_09_220708) do
|
||||||
|
create_table "discord_users", force: :cascade do |t|
|
||||||
|
t.string "discord_id"
|
||||||
|
t.string "username"
|
||||||
|
t.string "discriminator"
|
||||||
|
t.string "avatar"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "users", force: :cascade do |t|
|
||||||
|
t.string "provider"
|
||||||
|
t.string "uid"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
7
db/seeds.rb
Normal file
7
db/seeds.rb
Normal 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 bin/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/assets/.keep
Normal file
0
lib/assets/.keep
Normal file
|
@ -1,96 +0,0 @@
|
||||||
import { getSession } from "next-auth/react";
|
|
||||||
import prisma from "./prisma";
|
|
||||||
|
|
||||||
export const getBorderById = async (id) => {
|
|
||||||
return await prisma.borderImage.findFirst({
|
|
||||||
where: {
|
|
||||||
id: parseInt(id),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const countAllBorders = async () => {
|
|
||||||
return await prisma.borderImage.count();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getAllBorders = async (limit = undefined, cursor = undefined) => {
|
|
||||||
const sanitizedLimit = parseInt(limit) || undefined;
|
|
||||||
const sanitizedCursor = parseInt(cursor) || 0;
|
|
||||||
return await prisma.borderImage.findMany({
|
|
||||||
take: sanitizedLimit,
|
|
||||||
cursor: {
|
|
||||||
id: sanitizedCursor,
|
|
||||||
},
|
|
||||||
orderBy: {
|
|
||||||
id: "asc",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getUserBorders = async (req) => {
|
|
||||||
const session = await getSession({ req });
|
|
||||||
if (!session) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const accountData = await prisma.account.findFirst({
|
|
||||||
where: {
|
|
||||||
userId: session.user.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const userData = await prisma.applicationUserData.findUnique({
|
|
||||||
where: {
|
|
||||||
userId: session.user.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!!userData) {
|
|
||||||
return userData;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await prisma.applicationUserData.create({
|
|
||||||
data: {
|
|
||||||
userId: session.user.id,
|
|
||||||
discordId: accountData.providerAccountId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setUserBorder = async (req, borderId) => {
|
|
||||||
const session = await getSession({ req });
|
|
||||||
if (!session) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const accountData = await prisma.account.findFirst({
|
|
||||||
where: {
|
|
||||||
userId: session.user.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateData = await prisma.applicationUserData.upsert({
|
|
||||||
create: {
|
|
||||||
userId: session.user.id,
|
|
||||||
discordId: accountData.providerAccountId,
|
|
||||||
borderId: parseInt(borderId),
|
|
||||||
},
|
|
||||||
update: {
|
|
||||||
borderId: parseInt(borderId),
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
userId: session.user.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return updateData;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getByDiscordId = async (id) => {
|
|
||||||
const userData = await prisma.applicationUserData.findUnique({
|
|
||||||
where: {
|
|
||||||
discordId: id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return userData?.borderId ? `${userData.borderId}` : undefined;
|
|
||||||
};
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { PrismaClient } from "@prisma/client";
|
|
||||||
|
|
||||||
let prisma;
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
|
||||||
prisma = new PrismaClient();
|
|
||||||
} else {
|
|
||||||
if (!global.prisma) {
|
|
||||||
global.prisma = new PrismaClient();
|
|
||||||
}
|
|
||||||
prisma = global.prisma;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default prisma;
|
|
0
lib/tasks/.keep
Normal file
0
lib/tasks/.keep
Normal file
0
log/.keep
Normal file
0
log/.keep
Normal file
|
@ -1,14 +0,0 @@
|
||||||
/** @type {import('next').NextConfig} */
|
|
||||||
|
|
||||||
const webpack = require("webpack");
|
|
||||||
const { parsed: environment } = require("dotenv").config();
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
webpack(config) {
|
|
||||||
config.plugins.push(new webpack.EnvironmentPlugin(environment));
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
images: {
|
|
||||||
domains: ["localhost", "borders.j4.pm", "cdn.discordapp.com"],
|
|
||||||
},
|
|
||||||
};
|
|
32
package.json
32
package.json
|
@ -1,32 +0,0 @@
|
||||||
{
|
|
||||||
"name": "borders",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "next dev",
|
|
||||||
"build": "next build",
|
|
||||||
"start": "next start -p 3080",
|
|
||||||
"lint": "next lint",
|
|
||||||
"ingest": "node util/ingest.js",
|
|
||||||
"get_data": "node util/get_data.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@next-auth/prisma-adapter": "^1.0.3",
|
|
||||||
"@prisma/client": "^3.12.0",
|
|
||||||
"dotenv": "^16.0.0",
|
|
||||||
"next": "12.1.4",
|
|
||||||
"next-auth": "^4.3.1",
|
|
||||||
"nextjs-cors": "^2.1.1",
|
|
||||||
"node-fetch": "^3.2.3",
|
|
||||||
"prisma": "^3.12.0",
|
|
||||||
"react": "18.0.0",
|
|
||||||
"react-dom": "18.0.0",
|
|
||||||
"react-infinite-scroll-component": "^6.1.0",
|
|
||||||
"rxjs": "^7.5.5",
|
|
||||||
"sharp": "^0.30.4"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "8.13.0",
|
|
||||||
"eslint-config-next": "12.1.4"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import "../styles/globals.css";
|
|
||||||
import { SessionProvider } from "next-auth/react";
|
|
||||||
import { Alert } from "../components/alert";
|
|
||||||
|
|
||||||
function MyApp({ Component, pageProps: { session, ...pageProps } }) {
|
|
||||||
return (
|
|
||||||
<SessionProvider session={session}>
|
|
||||||
<Alert fade={true} />
|
|
||||||
<Component {...pageProps} />
|
|
||||||
</SessionProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default MyApp;
|
|
|
@ -1,35 +0,0 @@
|
||||||
import NextAuth from "next-auth";
|
|
||||||
import DiscordProvider from "next-auth/providers/discord";
|
|
||||||
import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
|
||||||
import prisma from "../../../lib/prisma";
|
|
||||||
|
|
||||||
export default NextAuth({
|
|
||||||
adapter: PrismaAdapter(prisma),
|
|
||||||
providers: [
|
|
||||||
DiscordProvider({
|
|
||||||
clientId: process.env.DISCORD_CLIENT_ID,
|
|
||||||
clientSecret: process.env.DISCORD_CLIENT_SECRET,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
callbacks: {
|
|
||||||
async signIn({ user, account, profile, email, credentials }) {
|
|
||||||
// console.log(user, account, profile, email, credentials);
|
|
||||||
if (user.image != profile.image_url) {
|
|
||||||
await prisma.user.update({
|
|
||||||
data: {
|
|
||||||
image: profile.image_url,
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
id: user.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
async session({ session, token, user }) {
|
|
||||||
session.user.id = user.id;
|
|
||||||
// console.log(JSON.stringify(user));
|
|
||||||
return session;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,13 +0,0 @@
|
||||||
import NextCors from "nextjs-cors";
|
|
||||||
import { getBorderById } from "../../../lib/borders";
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
|
||||||
const id = req.query.id;
|
|
||||||
await NextCors(req, res, {
|
|
||||||
methods: ["GET", "HEAD"],
|
|
||||||
origin: "*",
|
|
||||||
optionsSuccessStatus: 200,
|
|
||||||
});
|
|
||||||
const result = await getBorderById(id);
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
import { getAllBorders, countAllBorders } from "../../../lib/borders";
|
|
||||||
|
|
||||||
export default function handler(req, res) {
|
|
||||||
getAllBorders(req.query?.limit, req.query?.cursor).then((result) => {
|
|
||||||
countAllBorders().then((count) => {
|
|
||||||
return res.status(200).json({ data: result, count });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
||||||
|
|
||||||
export default function handler(req, res) {
|
|
||||||
res.status(200).json({
|
|
||||||
ok: "ok",
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { getUserBorders, setUserBorder } from "../../../../lib/borders";
|
|
||||||
|
|
||||||
export default function handler(req, res) {
|
|
||||||
if (req.method === "POST") {
|
|
||||||
setUserBorder(req, req.body).then((result) => {
|
|
||||||
if (result) {
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else {
|
|
||||||
return res.status(500).json({ error: "could not update border" });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
getUserBorders(req).then((result) => {
|
|
||||||
if (result) {
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else {
|
|
||||||
return res.status(404).json({ error: "Not Found" });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import NextCors from "nextjs-cors";
|
|
||||||
import { getByDiscordId } from "../../../../lib/borders";
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
|
||||||
const id = req.query.id;
|
|
||||||
|
|
||||||
await NextCors(req, res, {
|
|
||||||
methods: ["GET", "HEAD"],
|
|
||||||
origin: "*",
|
|
||||||
optionsSuccessStatus: 200,
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await getByDiscordId(id);
|
|
||||||
const borderUrl = result ?? "0";
|
|
||||||
|
|
||||||
return res.status(200).send(borderUrl);
|
|
||||||
}
|
|
113
pages/index.js
113
pages/index.js
|
@ -1,113 +0,0 @@
|
||||||
import Head from "next/head";
|
|
||||||
import Image from "next/image";
|
|
||||||
import Router from "next/router";
|
|
||||||
import styles from "../styles/Home.module.css";
|
|
||||||
import UserInfo from "../components/userInfo";
|
|
||||||
import Preview from "../components/borderPreview";
|
|
||||||
import Select from "../components/select";
|
|
||||||
import { alertService } from "../services";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
export default function Home() {
|
|
||||||
const [data, setData] = useState([]);
|
|
||||||
const [total, setTotal] = useState(0);
|
|
||||||
const [borderData, setBorderData] = useState(null);
|
|
||||||
const [selected, setSelected] = useState(0);
|
|
||||||
|
|
||||||
// const pageSize = 36;
|
|
||||||
|
|
||||||
const [cursor, setCursor] = useState(0);
|
|
||||||
|
|
||||||
// const fetchMore = () => {
|
|
||||||
// console.log("fetch more");
|
|
||||||
// fetch(`api/border/all?limit=${pageSize}&cursor=${cursor}`)
|
|
||||||
// .then((res) => res.json())
|
|
||||||
// .then((res) => {
|
|
||||||
// setData([...data, ...res.data]);
|
|
||||||
// setTotal(res.count);
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
const applyBorder = () => {
|
|
||||||
// console.log("apply");
|
|
||||||
fetch("api/user/border/@me", { method: "POST", body: selected })
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((res) => {
|
|
||||||
// console.log(res);
|
|
||||||
if (res.error) {
|
|
||||||
alertService.error(`error: ${res.error}`);
|
|
||||||
} else {
|
|
||||||
setBorderData(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetch("api/user/border/@me")
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((dat) => {
|
|
||||||
// console.log("border data", dat);
|
|
||||||
setBorderData(dat);
|
|
||||||
setSelected(dat?.borderId || 0);
|
|
||||||
});
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetch(`api/border/all`)
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => {
|
|
||||||
setData(data.data);
|
|
||||||
setTotal(data.count);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// let final = data?.[data?.length - 1];
|
|
||||||
// if (final) {
|
|
||||||
// setCursor(parseInt(final.id) + 1);
|
|
||||||
// console.log(cursor);
|
|
||||||
// }
|
|
||||||
// }, [data, cursor]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const timer = setTimeout(() => {
|
|
||||||
// if data has not loaded in 5 seconds
|
|
||||||
if (!data || !borderData) {
|
|
||||||
// console.log(data, borderData);
|
|
||||||
Router.reload();
|
|
||||||
} else {
|
|
||||||
console.log("data loaded properly, not reloading.");
|
|
||||||
}
|
|
||||||
}, 5000);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}, [data, borderData]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.container}>
|
|
||||||
<Head>
|
|
||||||
<title>Borders</title>
|
|
||||||
<link rel="icon" href="/favicon.ico" />
|
|
||||||
</Head>
|
|
||||||
<header>
|
|
||||||
<h1 className={styles.title}>Steam Borders</h1>
|
|
||||||
<div className={styles.userinfo}>
|
|
||||||
<UserInfo borderData={borderData} />
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
<Preview
|
|
||||||
data={data}
|
|
||||||
current={borderData?.borderId}
|
|
||||||
selected={selected}
|
|
||||||
apply={applyBorder}
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
data={data}
|
|
||||||
total={total}
|
|
||||||
onSelect={setSelected}
|
|
||||||
selected={selected}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
2307
pnpm-lock.yaml
2307
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,68 +0,0 @@
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "Account" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"type" TEXT NOT NULL,
|
|
||||||
"provider" TEXT NOT NULL,
|
|
||||||
"providerAccountId" TEXT NOT NULL,
|
|
||||||
"refresh_token" TEXT,
|
|
||||||
"access_token" TEXT,
|
|
||||||
"expires_at" INTEGER,
|
|
||||||
"token_type" TEXT,
|
|
||||||
"scope" TEXT,
|
|
||||||
"id_token" TEXT,
|
|
||||||
"session_state" TEXT,
|
|
||||||
CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "Session" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"sessionToken" TEXT NOT NULL,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"expires" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "User" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"name" TEXT,
|
|
||||||
"email" TEXT,
|
|
||||||
"emailVerified" DATETIME,
|
|
||||||
"image" TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "VerificationToken" (
|
|
||||||
"identifier" TEXT NOT NULL,
|
|
||||||
"token" TEXT NOT NULL,
|
|
||||||
"expires" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "ApplicationUserData" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"discordId" TEXT NOT NULL,
|
|
||||||
"borderUrl" TEXT,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "ApplicationUserData_discordId_key" ON "ApplicationUserData"("discordId");
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `discordId` on the `ApplicationUserData` table. All the data in the column will be lost.
|
|
||||||
- Added the required column `userId` to the `ApplicationUserData` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- RedefineTables
|
|
||||||
PRAGMA foreign_keys=OFF;
|
|
||||||
CREATE TABLE "new_ApplicationUserData" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"borderUrl" TEXT,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
INSERT INTO "new_ApplicationUserData" ("borderUrl", "createdAt", "id", "updatedAt") SELECT "borderUrl", "createdAt", "id", "updatedAt" FROM "ApplicationUserData";
|
|
||||||
DROP TABLE "ApplicationUserData";
|
|
||||||
ALTER TABLE "new_ApplicationUserData" RENAME TO "ApplicationUserData";
|
|
||||||
CREATE UNIQUE INDEX "ApplicationUserData_userId_key" ON "ApplicationUserData"("userId");
|
|
||||||
PRAGMA foreign_key_check;
|
|
||||||
PRAGMA foreign_keys=ON;
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `discordId` to the `ApplicationUserData` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- RedefineTables
|
|
||||||
PRAGMA foreign_keys=OFF;
|
|
||||||
CREATE TABLE "new_ApplicationUserData" (
|
|
||||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"discordId" TEXT NOT NULL,
|
|
||||||
"borderUrl" TEXT,
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
INSERT INTO "new_ApplicationUserData" ("borderUrl", "createdAt", "id", "updatedAt", "userId") SELECT "borderUrl", "createdAt", "id", "updatedAt", "userId" FROM "ApplicationUserData";
|
|
||||||
DROP TABLE "ApplicationUserData";
|
|
||||||
ALTER TABLE "new_ApplicationUserData" RENAME TO "ApplicationUserData";
|
|
||||||
CREATE UNIQUE INDEX "ApplicationUserData_userId_key" ON "ApplicationUserData"("userId");
|
|
||||||
CREATE UNIQUE INDEX "ApplicationUserData_discordId_key" ON "ApplicationUserData"("discordId");
|
|
||||||
PRAGMA foreign_key_check;
|
|
||||||
PRAGMA foreign_keys=ON;
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue