-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 14efe80
Showing
101 changed files
with
13,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
AUTHENTICATION_EXPIRATION=24 | ||
DATABASE_HOST=localhost | ||
DATABASE_PORT=5432 | ||
DATABASE_USERNAME=user | ||
DATABASE_PASSWORD=1234 | ||
DATABASE_NAME=dev | ||
SECRET_KEY_BASE=somethingsecure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore the default SQLite database. | ||
/db/*.sqlite3 | ||
/db/*.sqlite3-* | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
# Ignore pidfiles, but keep the directory. | ||
/tmp/pids/* | ||
!/tmp/pids/ | ||
!/tmp/pids/.keep | ||
|
||
# Ignore uploaded files in development. | ||
/storage/* | ||
!/storage/.keep | ||
/tmp/storage/* | ||
!/tmp/storage/ | ||
!/tmp/storage/.keep | ||
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key | ||
|
||
# Ignore public folder | ||
/public | ||
|
||
# Ignore environment variables | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
ruby '3.1.2' | ||
|
||
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" | ||
gem 'rails', '~> 7.0.2', '>= 7.0.2.3' | ||
|
||
# Use Postgres as the database for Active Record | ||
gem 'pg' | ||
|
||
# Use the Puma web server [https://github.com/puma/puma] | ||
gem 'puma', '~> 5.0' | ||
|
||
# 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 | ||
|
||
# Pagination | ||
gem 'pagy', '~> 5.10' | ||
|
||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible | ||
gem 'rack-cors' | ||
|
||
# Resource API | ||
gem 'resource_api', git: 'https://github.com/performant-software/resource-api.git', tag: 'v0.4.2' | ||
|
||
# Use Json Web Token (JWT) for token based authentication | ||
gem 'jwt', '~> 2.4', '>= 2.4.1' | ||
|
||
# Use ActiveModel has_secure_password | ||
gem 'bcrypt', '~> 3.1.18' | ||
|
||
# Controlled vocabularies | ||
gem 'controlled_vocabulary', git: 'https://github.com/performant-software/controlled-vocabulary.git', tag: 'v0.1.3' | ||
|
||
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 ] | ||
|
||
# Environment variable management | ||
gem 'dotenv-rails' | ||
end | ||
|
||
group :development do | ||
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] | ||
# gem "spring" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
GIT | ||
remote: https://github.com/performant-software/controlled-vocabulary.git | ||
revision: 79e776e47197afaed4e2a910fb99578b129dc16f | ||
tag: v0.1.3 | ||
specs: | ||
controlled_vocabulary (0.1.1) | ||
pagy (~> 5.10) | ||
rails (>= 6.0.3.2, < 8) | ||
resource_api | ||
|
||
GIT | ||
remote: https://github.com/performant-software/resource-api.git | ||
revision: f1de1653b67fc1d623d7418e92d3bb3134df800e | ||
tag: v0.4.2 | ||
specs: | ||
resource_api (0.1.0) | ||
pagy (~> 5.10) | ||
rails (>= 6.0.3.2, < 8) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actioncable (7.0.2.4) | ||
actionpack (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
nio4r (~> 2.0) | ||
websocket-driver (>= 0.6.1) | ||
actionmailbox (7.0.2.4) | ||
actionpack (= 7.0.2.4) | ||
activejob (= 7.0.2.4) | ||
activerecord (= 7.0.2.4) | ||
activestorage (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
mail (>= 2.7.1) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
actionmailer (7.0.2.4) | ||
actionpack (= 7.0.2.4) | ||
actionview (= 7.0.2.4) | ||
activejob (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
mail (~> 2.5, >= 2.5.4) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
rails-dom-testing (~> 2.0) | ||
actionpack (7.0.2.4) | ||
actionview (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
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.4) | ||
actionpack (= 7.0.2.4) | ||
activerecord (= 7.0.2.4) | ||
activestorage (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
globalid (>= 0.6.0) | ||
nokogiri (>= 1.8.5) | ||
actionview (7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
builder (~> 3.1) | ||
erubi (~> 1.4) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.1, >= 1.2.0) | ||
activejob (7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
globalid (>= 0.3.6) | ||
activemodel (7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
activerecord (7.0.2.4) | ||
activemodel (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
activestorage (7.0.2.4) | ||
actionpack (= 7.0.2.4) | ||
activejob (= 7.0.2.4) | ||
activerecord (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
marcel (~> 1.0) | ||
mini_mime (>= 1.1.0) | ||
activesupport (7.0.2.4) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
bcrypt (3.1.18) | ||
bootsnap (1.11.1) | ||
msgpack (~> 1.2) | ||
builder (3.2.4) | ||
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) | ||
globalid (1.0.0) | ||
activesupport (>= 5.0) | ||
i18n (1.10.0) | ||
concurrent-ruby (~> 1.0) | ||
io-console (0.5.11) | ||
irb (1.4.1) | ||
reline (>= 0.3.0) | ||
jwt (2.4.1) | ||
loofah (2.17.0) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.5.9) | ||
mail (2.7.1) | ||
mini_mime (>= 0.1.1) | ||
marcel (1.0.2) | ||
method_source (1.0.0) | ||
mini_mime (1.1.2) | ||
mini_portile2 (2.8.0) | ||
minitest (5.15.0) | ||
msgpack (1.5.1) | ||
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.4) | ||
mini_portile2 (~> 2.8.0) | ||
racc (~> 1.4) | ||
nokogiri (1.13.4-x86_64-darwin) | ||
racc (~> 1.4) | ||
pagy (5.10.1) | ||
activesupport | ||
pg (1.2.3) | ||
puma (5.6.4) | ||
nio4r (~> 2.0) | ||
racc (1.6.0) | ||
rack (2.2.3) | ||
rack-cors (1.1.1) | ||
rack (>= 2.0.0) | ||
rack-test (1.1.0) | ||
rack (>= 1.0, < 3) | ||
rails (7.0.2.4) | ||
actioncable (= 7.0.2.4) | ||
actionmailbox (= 7.0.2.4) | ||
actionmailer (= 7.0.2.4) | ||
actionpack (= 7.0.2.4) | ||
actiontext (= 7.0.2.4) | ||
actionview (= 7.0.2.4) | ||
activejob (= 7.0.2.4) | ||
activemodel (= 7.0.2.4) | ||
activerecord (= 7.0.2.4) | ||
activestorage (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
bundler (>= 1.15.0) | ||
railties (= 7.0.2.4) | ||
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.4) | ||
actionpack (= 7.0.2.4) | ||
activesupport (= 7.0.2.4) | ||
method_source | ||
rake (>= 12.2) | ||
thor (~> 1.0) | ||
zeitwerk (~> 2.5) | ||
rake (13.0.6) | ||
reline (0.3.1) | ||
io-console (~> 0.5) | ||
strscan (3.0.1) | ||
thor (1.2.1) | ||
timeout (0.2.0) | ||
tzinfo (2.0.4) | ||
concurrent-ruby (~> 1.0) | ||
websocket-driver (0.7.5) | ||
websocket-extensions (>= 0.1.0) | ||
websocket-extensions (0.1.5) | ||
zeitwerk (2.5.4) | ||
|
||
PLATFORMS | ||
ruby | ||
x86_64-darwin-19 | ||
|
||
DEPENDENCIES | ||
bcrypt (~> 3.1.18) | ||
bootsnap | ||
controlled_vocabulary! | ||
debug | ||
dotenv-rails | ||
jwt (~> 2.4, >= 2.4.1) | ||
pagy (~> 5.10) | ||
pg | ||
puma (~> 5.0) | ||
rack-cors | ||
rails (~> 7.0.2, >= 7.0.2.3) | ||
resource_api! | ||
tzinfo-data | ||
|
||
RUBY VERSION | ||
ruby 3.1.2p20 | ||
|
||
BUNDLED WITH | ||
2.3.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: bundle exec puma -C config/puma.rb | ||
release: bin/rake db:migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: cd client && npm start --port 3000 | ||
api: bundle exec rails s -p 3001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# rails-react-template | ||
|
||
## Requirements | ||
|
||
- macOS or Linux | ||
- Ruby version that matches the `.ruby-version` file. ([rbenv](https://github.com/rbenv/rbenv) is recommended for managing Ruby versions) | ||
- Node 18 ([nvm](https://github.com/nvm-sh/nvm) is likewise recommended) | ||
- Postgres (this template is confirmed to work with Postgres 18, but any reasonably recent version should work) | ||
- Heroku CLI (optional, if you want to deploy on Heroku) | ||
|
||
## Setup | ||
|
||
1. Create a Postgres user by running `createuser [username] -d`. | ||
2. Launch `psql` and create a database for your project, and set it to be owned by the user you created in step 1. | ||
3. Create an `.env` file in the root folder of this project, following the format of `.env.example`. | ||
4. For the `SECRET_KEY_BASE` env parameter, you can generate a secure value by running `bundle exec rails secret`. | ||
5. Run `bundle install` to install the gems from the Gemfile. | ||
6. Run `npm run build`, which installs Node dependencies and builds the browser app. | ||
7. Create an app on Heroku. | ||
8. Now you should be able to deploy to Heroku as covered [in their docs](https://devcenter.heroku.com/articles/git). | ||
|
||
## Development | ||
|
||
Use `bundle exec rake start` to start a live development build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module ApplicationCable | ||
class Channel < ActionCable::Channel::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Api::AuthenticationController < Api::BaseController | ||
# Actions | ||
skip_before_action :authenticate_request | ||
|
||
DEFAULT_EXPIRATION = '24' | ||
|
||
def login | ||
user = User.find_by_email(params[:email]) | ||
|
||
if user&.authenticate(params[:password]) | ||
token = JsonWebToken.encode(user_id: user.id) | ||
time = Time.now + ENV.fetch('AUTHENTICATION_EXPIRATION') { DEFAULT_EXPIRATION }.to_i.hours.to_i | ||
render json: { token: token, exp: time.iso8601, username: user.email }, status: :ok | ||
else | ||
render json: { error: 'unauthorized' }, status: :unauthorized | ||
end | ||
end | ||
end |
Oops, something went wrong.